QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#732250 | #5499. Aliases | arnold518# | AC ✓ | 862ms | 25288kb | C++17 | 1.3kb | 2024-11-10 13:47:17 | 2024-11-10 13:47:17 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef long long lint;
const int N = 200005;
int n;
string a[N], b[N];
map<int, int> mp;
bool can (int A, int B, int C) {
mp.clear();
int L = 1;
for (int i=0;i<C;i++) {
L *= 10;
}
for (int i=1;i<=n;i++) {
int I = 0;
for(int j=0;j<A;j++) {
if (a[i].size() <= j) break;
int X = (a[i].size() <= j ? 0 : a[i][j] - 'a' + 1);
I = I * 27 + X;
}
for(int j=0;j<B;j++) {
if (b[i].size() <= j) break;
int X = (b[i].size() <= j ? 0 : b[i][j] - 'a' + 1);
I = I * 27 + X;
}
if (++mp[I] > L) return false;
}
return true;
}
void solve () {
cin >> n;
for (int i=1;i<=n;i++) {
cin >> a[i] >> b[i];
}
for (int x=1;;x++) {
for (int a=0;a<=x;a++) for (int b=0;a+b<=x;b++) {
int c = x - a - b;
if (can(a, b, c)) {
printf("%d %d %d\n", a, b, c);
return;
}
}
}
}
int main()
{
ios_base::sync_with_stdio(false); cin.tie(NULL);
int TC;
cin >> TC;
// scanf("%d", &TC);
while(TC--)
{
solve();
}
}
详细
Test #1:
score: 100
Accepted
time: 4ms
memory: 16356kb
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: 9ms
memory: 16852kb
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: 39ms
memory: 19544kb
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: 862ms
memory: 21016kb
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: 345ms
memory: 25288kb
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)