QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#178149 | #5499. Aliases | real_sigma_team# | AC ✓ | 6519ms | 26328kb | C++20 | 1.6kb | 2023-09-13 18:36:32 | 2023-09-13 18:36:33 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
using ll = long long;
const int N = 3e5 + 5;
int ask(int x) {
cout << x << endl;
cin >> x;
return x;
}
int lg10(ll x) {
int pw = 0;
int cur = 1;
while (cur < x) {
pw++;
cur *= 10;
}
return pw;
}
void solve() {
int n;
cin >> n;
vector<pair<string, string>> a(n);
for (auto &[x, y]: a) cin >> x >> y;
pair<pair<int, int>, int> ans = {{0, 0},
{lg10(n)}};
for (int i = 0; i <= lg10(n); ++i) {
for (int j = 0; i + j <= lg10(n); ++j) {
map<string, int> cnt;
for (auto [x, y] : a) {
string cur = "";
cur += string(x.begin(), x.begin() + min((int)x.size(), i));
cur += string(y.begin(), y.begin() + min((int)y.size(), j));
cnt[cur]++;
}
int mx = 0;
for (auto &[x, y] : cnt) {
mx = max(mx, lg10(y));
}
if (i + j + mx <= ans.first.first + ans.first.second + ans.second) {
ans = {{i, j}, mx};
}
}
}
if (ans == make_pair(make_pair(0, 0), 0)) {
ans = {{0, 0}, 1};
}
cout << ans.first.first << ' ' << ans.first.second << ' ' << ans.second << '\n';
}
int main() {
#ifndef LOCAL
#else
freopen("input.txt", "r", stdin);
#endif
int t;
cin >> t;
while (t--)
solve();
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3604kb
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:
1 1 0
result:
ok correct! (1 test case)
Test #2:
score: 0
Accepted
time: 45ms
memory: 5288kb
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 1 1 1 0 2 1 1 1 2 0 1
result:
ok correct! (6 test cases)
Test #3:
score: 0
Accepted
time: 351ms
memory: 7120kb
input:
6 5000 dpbcebnavonpwlkermqftinonhckqynyxfwsybsalgmpqmedykqeunbolxhtcnrvbiqrjgziptkqgbsxrprapfzjxefiioecsacujyuhvsapywqohliffaqsbupnocesbgqutaanduiztwwqulwvrx dyearafwtdkifljtvcryeyfzgqghjwhuycusqkxngmanxxjhyqaethbfoqaigbbjuutwzzazsgcguaasrrrzsapcuhvzzjllatjqtxzrotdpcrrdogfwoonxjwisdwhqntlhqpflxvcido...
output:
3 0 1 0 1 3 1 1 2 2 0 2 1 2 1 3 0 1
result:
ok correct! (6 test cases)
Test #4:
score: 0
Accepted
time: 6519ms
memory: 19804kb
input:
6 113503 hxihfx mrqehftb oqmcc bwrbqomg dokyjc kuaiu hhfubp aleme xcnbe shxaqrf kzmqym geclklta jnxjq nppjx xeloxixa owsxnnj pzlvbyuk leioq xipez hoxgsml esujubw cwwzpei fekvoee vbxlts xjhcrkx qicmbmen rskvnrcx mpzpvvye lkkmkstn wlptoh wqgvr qbryq cqxydbr fzdxdrv wzofngxt keqwwhdl fkomzb sckpev geqe...
output:
4 0 1 2 2 1 1 3 1 3 0 2 1 2 2 1 1 3
result:
ok correct! (6 test cases)
Test #5:
score: 0
Accepted
time: 4177ms
memory: 26328kb
input:
6 1331 hidkxivneczxfctnobbqpxsgneaivgbodiejoqgbdthwsdsfzkxcdtzumcfdoawihskkwkehjdezgazzphrnkgncimntusqjqwimwbsztbzceqnwmnzzezwzazakknfwvdsyglpplwgnhwcgpriuwdmbvvlxaoruuuugamntnuqlvslsgvehhegjqpkcskonosndngfkokjcrqewtzzmypimrsoqqffwwzgzwhgfrrxmtptzfnretnoqjprpgqdhxcrccphsdmouuuidojxcyiknpfrrygjgwgwkb...
output:
1 2 0 3 1 0 4 1 0 2 3 0 0 5 0 0 0 6
result:
ok correct! (6 test cases)