QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#221601 | #5499. Aliases | ucup-team859# | WA | 52ms | 5000kb | C++17 | 1.8kb | 2023-10-21 13:55:37 | 2023-10-21 13:55:37 |
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};
}
}
}
cout << sol[0] << " " << sol[1] << " " << sol[2] << "\n";
}
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 1ms
memory: 3456kb
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: 52ms
memory: 5000kb
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)