QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#105309 | #5499. Aliases | cciafrino# | WA | 239ms | 5348kb | C++17 | 1.4kb | 2023-05-13 21:42:54 | 2023-05-13 21:42:55 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
int main() {
cin.tie(nullptr)->sync_with_stdio(false);
int T; cin >> T;
while (T--) {
int N; cin >> N;
vector<array<string, 2>> S(N);
for (auto& [n, s] : S) {
cin >> n >> s;
}
vector<int> pw(10);
pw[0] = 1;
for (int i = 1; i < 10; ++i) {
pw[i] = pw[i - 1] * 10;
}
map<string, int> freq;
array<int, 3> ans = {10, 10, 10};
for (int a = 0; a < 7; ++a) {
for (int b = 0; b < 7; ++b) {
for (int c = 0; c < 7; ++c) {
if (a+b+c == 0 || a+b+c > 6) continue;
for (int i = 0; i < N; ++i) {
string P = S[i][0].substr(0, a) + S[i][1].substr(0, b);
freq[P] += 1;
}
bool is_ok = true;
for (auto& [s, val] : freq) {
if (val > pw[c]) is_ok = false;
}
if (!is_ok) continue;
int cur_sum = 0;
for (int v : ans) cur_sum += v;
if (a+b+c < cur_sum) {
ans = {a, b, c};
}
}
}
}
for (int v : ans) cout << v << ' ';
cout << '\n';
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3460kb
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: 239ms
memory: 5348kb
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 0 3 0 0 4 0 0 4 0 0 4
result:
wrong answer Rozwiazanie nieoptymalne! (test case 3)