QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#259774 | #5499. Aliases | w4p3r# | WA | 47ms | 129804kb | C++20 | 1.6kb | 2023-11-21 13:34:56 | 2023-11-21 13:34:57 |
Judging History
answer
#include<bits/stdc++.h>
#define inf 1e9
#define eps 1e-6
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define REP(i,a,b) for(int i=a;i>=b;i--)
#define db double
#define ve vector<int>
#define pa pair<int,int>
#define fr first
#define sd second
#define pb push_back
#define mp make_pair
#define MEM(a) memset(a,0,sizeof(a))
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
inline ll read()
{
char ch = getchar();
ll s = 0, w = 1;
while (ch < '0' || ch > '9') {if (ch == '-')w = -1; ch = getchar();}
while (ch >= '0' && ch <= '9') {s = s * 10 + ch - '0'; ch = getchar();}
return s * w;
}
#define N 2000010
string s[N], t[N];
map<string, int>ma;
int n;
const int qlg(int x)
{
int s = 0, w = 1;
while (w < x)w *= 10, s ++;
return s;
}
int sol(int p, int q)
{
int ans = 0;
for (int i = 1; i <= n; i ++)
{
string a = "";
for (int j = 0; j < min(p, (int)s[i].length()); j ++)a += s[i][j];
for (int j = 0; j < min(q, (int)t[i].length()); j ++)a += t[i][j];
ans = max(ans, ++ma[a]);
}
ma.clear(); return ans;
}
void sol()
{
cin >> n;
for (int i = 1; i <= n; i ++)cin >> s[i] >> t[i];
int ans = 6, A = 0, B = 0, C = 6;
for (int a = 0; a <= 5; a ++)for (int b = 0; a + b <= 5; b ++)
{
int c = qlg(sol(a, b));
if (a + b + c < ans)ans = a + b + c, A = a, B = b, C = c;
}
cout << A << ' ' << B << ' ' << C << '\n';
}
signed main()
{
//freopen(".in","r",stdin);
//freopen(".out","w",stdout);
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int T; cin >> T;
while (T --)sol();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 16ms
memory: 128860kb
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: -100
Wrong Answer
time: 47ms
memory: 129804kb
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 0 0 0 5 0 1 1 1 0 2 1 1 1 2 0 1
result:
wrong answer Loginy nie moga byc puste! (test case 1)