QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#221622 | #5499. Aliases | ucup-team859# | WA | 56ms | 5180kb | C++17 | 1.9kb | 2023-10-21 14:02:02 | 2023-10-21 14:02:02 |
Judging History
answer
#include <bits/stdc++.h>
#define lsb(x) (x & (-x))
using ull = unsigned long long;
using ll = long long;
using namespace std;
int main() {
#ifdef HOME
ifstream cin("input.in");
ofstream cout("output.out");
#endif
ios::sync_with_stdio(false);
cin.tie(0), cout.tie(0);
int t;
cin >> t;
for (int tt = 1; tt <= t; tt++) {
int n;
cin >> n;
vector<string> A(n), B(n);
for (int i = 0; i < n; i++) {
cin >> A[i] >> B[i];
}
constexpr int MAXANS = 6;
int answer = MAXANS;
vector<int> sol = {0, 0, MAXANS};
vector<pair<string, string>> temp(n);
for (int a = 0; a <= MAXANS; a++) {
for (int b = 0; a + b <= MAXANS; b++) {
if (a + b > answer) continue;
for (int i = 0; i < n; i++) {
temp[i] = {A[i].substr(0, a), B[i].substr(0, b)};
}
sort(temp.begin(), temp.end());
auto Get = [](int x) {
int pw = 1, e = 0;
while (pw < x) {
pw *= 10;
e++;
}
return e;
};
int c = 0;
int i = 0;
while (i < n) {
int j = i;
while (j < n && temp[i] == temp[j]) {
j++;
}
c = max(c, Get(j - i));
i = j;
}
if (answer > a + b + c) {
answer = a + b + c;
sol = {a, b, c};
}
}
}
if (answer == 0) {
sol[2] = 1;
}
cout << sol[0] << " " << sol[1] << " " << sol[2] << "\n";
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3824kb
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: 56ms
memory: 5180kb
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 0 0 1 1 1 0 2 1 1 1 2 0 1
result:
wrong answer Loginy nieunikalne! (test case 2)