QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#485112 | #5499. Aliases | Andeviking# | WA | 95ms | 8716kb | C++20 | 2.1kb | 2024-07-20 13:03:46 | 2024-07-20 13:03:46 |
Judging History
answer
#pragma GCC optimize(2)
#include<bits/stdc++.h>
#include<bits/extc++.h>
using namespace std;
typedef long long ll;
typedef __int128_t int128;
typedef pair<int, int> pii;
#define iofast ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define lowbit(x) (x&(-x))
#define inv(x) qpow(x,mod-2)
#define debug(x) cout << (#x) << " = " << x << endl
#define range(x) (x).begin(), (x).end()
const int iINF = 0x3f3f3f3f;
const ll llINF = 0x3f3f3f3f3f3f3f3f;
const ll mod = 998244353;
/*---------------------------------------*/
void solve()
{
int n;
cin>>n;
string s;
vector<pair<string,string>>use;
for(int i=1;i<=n;++i){
while(s.size()<3)
getline(cin,s,'\n');
string a,b;
int pos=0;
while(s[pos]!=' ')
a+=s[pos],pos++;
pos++;
for(int i=pos;i<s.size();++i)
b+=s[i];
use.emplace_back(a,b);
s.clear();
}
for(int i=1;i<=6;++i){
for(int u=0;u<=i;++u)
for(int v=0;v+u<=i;++v){
int k=i-v-u;
__gnu_pbds::gp_hash_table<string,int>mp;
for(const auto& [x,y]:use){
string s;
if(x.size()<=u)
s+=x;
else
s+=x.substr(0,u);
if(y.size()<=v)
s+=y;
else
s+=y.substr(0,v);
mp[s]++;
}
bool flag=true;
for(const auto& [key,val]:mp){
if(to_string(val).size()>k){
flag=false;
break;
}
}
if(flag){
cout<<u<<' '<<v<<' '<<k<<'\n';
return;
}
}
}
}
/*---------------------------------------*/
int main()
{
iofast;
int t = 1;
cin >> t;
while (t--)
solve();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3600kb
input:
1 11 sven eriksson erik svensson sven svensson erik eriksson bjorn eriksson bjorn svensson bjorn bjornsson erik bjornsson sven bjornsson thor odinsson odin thorsson
output:
0 0 2
result:
ok correct! (1 test case)
Test #2:
score: 0
Accepted
time: 18ms
memory: 7136kb
input:
6 1 g u 14643 gj ek hc bi hi ke ab ij hk cj ha bi ag fe eb ej hd ei bf gj ke dd ib jd id jb gd ei cj bi bi hg ic dh ke gk af eg fg dd fe fa be ge hf kj ih ci gg jf ed dd eh gi cc kd ka fd af gb ka fe ja ed bc hi eg cf gg ff kf gf ii ch hh ec ei ec cd gc bh hb dd id ce bk ib ic bf kk gh cd hb he if g...
output:
0 0 1 0 0 5 0 1 1 1 0 2 1 1 1 2 0 1
result:
ok correct! (6 test cases)
Test #3:
score: -100
Wrong Answer
time: 95ms
memory: 8716kb
input:
6 5000 dpbcebnavonpwlkermqftinonhckqynyxfwsybsalgmpqmedykqeunbolxhtcnrvbiqrjgziptkqgbsxrprapfzjxefiioecsacujyuhvsapywqohliffaqsbupnocesbgqutaanduiztwwqulwvrx dyearafwtdkifljtvcryeyfzgqghjwhuycusqkxngmanxxjhyqaethbfoqaigbbjuutwzzazsgcguaasrrrzsapcuhvzzjllatjqtxzrotdpcrrdogfwoonxjwisdwhqntlhqpflxvcido...
output:
0 0 4 0 1 3 1 1 2 2 0 2 1 2 1 0 0 5
result:
wrong answer Rozwiazanie nieoptymalne! (test case 6)