QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#150036 | #5499. Aliases | ahsoltan | AC ✓ | 1030ms | 30400kb | C++17 | 1.4kb | 2023-08-25 14:58:00 | 2023-08-25 14:58:03 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#ifdef LOCAL
#include "debug.h"
#else
#define debug(...) 2137
#endif
int main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int tt;
cin >> tt;
while (tt--) {
int n;
cin >> n;
vector<vector<string>> s(n, vector<string>(2));
for (int i = 0; i < n; i++) {
cin >> s[i][0] >> s[i][1];
}
int a = 0;
int b = 0;
int c = 6;
for (int i = 0; i <= 6; i++) {
for (int j = 0; j <= 6; j++) {
for (int k = 0; k <= 6; k++) {
int mx = 1;
for (int l = 0; l < k; l++) {
mx *= 10;
}
if (i + j + k > 0 && i + j + k < a + b + c) {
bool ok = true;
map<ll, int> m;
for (int x = 0; x < n; x++) {
ll h = 0;
for (int p = 0; p < min(i, (int)s[x][0].size()); p++) {
h = h * 28 + (s[x][0][p] - 'a' + 1);
}
for (int p = 0; p < min(j, (int)s[x][1].size()); p++) {
h = h * 28 + (s[x][1][p] - 'a' + 1);
}
if (++m[h] > mx) {
ok = false;
break;
}
}
if (ok) {
a = i;
b = j;
c = k;
}
}
}
}
}
cout << a << ' ' << b << ' ' << c << '\n';
}
}
詳細信息
Test #1:
score: 100
Accepted
time: 2ms
memory: 3500kb
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: 0
Accepted
time: 5ms
memory: 5448kb
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 0 0 5 0 1 1 1 0 2 1 1 1 2 0 1
result:
ok correct! (6 test cases)
Test #3:
score: 0
Accepted
time: 47ms
memory: 6496kb
input:
6 5000 dpbcebnavonpwlkermqftinonhckqynyxfwsybsalgmpqmedykqeunbolxhtcnrvbiqrjgziptkqgbsxrprapfzjxefiioecsacujyuhvsapywqohliffaqsbupnocesbgqutaanduiztwwqulwvrx dyearafwtdkifljtvcryeyfzgqghjwhuycusqkxngmanxxjhyqaethbfoqaigbbjuutwzzazsgcguaasrrrzsapcuhvzzjllatjqtxzrotdpcrrdogfwoonxjwisdwhqntlhqpflxvcido...
output:
0 0 4 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: 1030ms
memory: 20900kb
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: 429ms
memory: 30400kb
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)