QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#606976 | #5499. Aliases | hzy99999# | WA | 31ms | 5920kb | C++20 | 1.7kb | 2024-10-03 13:23:58 | 2024-10-03 13:23:59 |
Judging History
answer
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <cmath>
#include <map>
#define x first
#define y second
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int, int> PII;
const int N = 2e5 + 10;
int T;
int n;
// string stra[N], strb[N];
map<pair<string, string>, int> p;
pair<PII, int> res;
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cin >> T;
while (T--)
{
cin >> n;
vector<string> stra(n + 1), strb(n + 1);
for (int i = 1; i <= n; i++)
cin >> stra[i] >> strb[i];
if (n == 1)
{
cout << "0 0 0" << endl;
continue;
}
// int ans = log(n - 1) / log(2) + 1;
int minv = 19;
for (int a = 0; a <= minv; a++)
for (int b = 0; a + b <= minv; b++)
{
p.clear();
int cnt = 0;
// cout << ':' << a << ' ' << b << endl;
for (int i = 1; i <= n; i++)
{
string ha = stra[i].substr(0, a), hb = strb[i].substr(0, b);
// cout << ha << ' ' << hb << endl;
int t = ++p[{ha, hb}];
cnt = max(cnt, t);
}
int c = cnt <= 1 ? 0 : log(cnt - 1) / log(10) + 1;
// cout << cnt << ' ' << minv << ' ' << a + b + c << endl;
if (minv > a + b + c)
minv = a + b + c, res = (pair<PII, int>){{a, b}, c};
}
cout << res.x.x << ' ' << res.x.y << ' ' << res.y << endl;
}
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3740kb
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: 31ms
memory: 5920kb
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 2 2 0 0 1 1 1 0 2 1 1 1 2 0 1
result:
wrong answer Loginy nie moga byc puste! (test case 1)