QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#145416 | #5499. Aliases | TJ_Andeviking | WA | 63ms | 5224kb | C++14 | 1.4kb | 2023-08-22 11:50:52 | 2023-08-22 11:50:53 |
Judging History
answer
#pragma GCC optimize(2)
#include<bits/stdc++.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;
vector<pair<string, string>>v(n);
for (auto& [x, y] : v)
cin >> x >> y;
int mi = iINF;
int a, b, c;
for (int i = 0;i <= 6;++i)
for (int j = 0;j + i <= 6;++j) {
map<string, int>mp;
for (const auto& [x, y] : v) {
mp[x.substr(0, min(int(x.size()), i)) + y.substr(0, min(int(y.size()), j))]++;
}
int k = 1;
for (const auto& [key, val] : mp)
k = max(k, val);
k--;
if (k)
k = to_string(k).size();
if (i + j + k < mi)
a = i, b = j, c = k, mi = i + j + k;
}
cout << a << ' ' << b << ' ' << c << '\n';
}
/*---------------------------------------*/
int main()
{
iofast;
int t = 1;
cin >> t;
while (t--)
solve();
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3456kb
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: 63ms
memory: 5224kb
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)