QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#189211 | #5499. Aliases | marta | WA | 102ms | 5720kb | C++14 | 1.1kb | 2023-09-27 00:41:36 | 2023-09-27 00:41:44 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
int t=1;
void solve()
{
int n;
cin>>n;
vector<string> imie(n), nazwisko(n);
for(int i=0; i<n; i++)
{
cin>>imie[i]>>nazwisko[i];
imie[i]+=" ";
nazwisko[i]+=" ";
}
int a=0, b=0, c=6;
map <string, int> mapa;
for(int i=0; i<=6; i++)
{
for(int j=0; j<=6; j++)
{
for(int k=0; k<=6; k++)
{
if(!(a+b+c) or a+b+c<=i+j+k) continue;
bool czyok=1;
for(int ii=0; ii<n; ii++)
{
string s;
s+=imie[ii].substr(0, i);
s+=nazwisko[ii].substr(0, j);
mapa[s]++;
if(mapa[s]>k*10) czyok=0;
}
if(czyok){a=i, b=j, c=k;}
}
}
}
cout<<a<<' '<<b<<' '<<c<<'\n';
}
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cin>>t;
while(t--) solve();
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3448kb
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 1 1
result:
ok correct! (1 test case)
Test #2:
score: -100
Wrong Answer
time: 102ms
memory: 5720kb
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 2 2 1 0 2 1 0 3 1 0 3 1 0 3 1
result:
wrong answer Rozwiazanie nieoptymalne! (test case 3)