QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#732192 | #5499. Aliases | arnold518# | WA | 7ms | 16984kb | C++17 | 1.2kb | 2024-11-10 13:38:24 | 2024-11-10 13:38:24 |
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++) {
int X = (a[i].size() <= j ? 0 : a[i][j] - 'a' + 1);
I = I * 27 + X;
}
for(int j=0;j<B;j++) {
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++) for (int c=0;a+b+c<=x;c++) {
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();
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 16408kb
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: 7ms
memory: 16984kb
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)