QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#77148 | #5499. Aliases | UCSC_Ravioli# | WA | 29ms | 65940kb | C++20 | 1.5kb | 2023-02-13 05:34:54 | 2023-02-13 05:34:58 |
Judging History
answer
// qdd on Feb 12, 2023
#ifdef qdd
#include <ringo>
#else
#include <bits/stdc++.h>
#define dbg(...)
#define dbgr(x, y)
#endif
using namespace std;
using ll = long long;
template <class T>
istream& operator>>(istream& is, vector<T>& v) {
for (T& x : v) is >> x;
return is;
}
template <class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
bool f = 0;
for (const T& x : v) (f ? os << ' ' : os) << x, f = 1;
return os;
}
const int N = 1e6 + 10;
int n;
string A[N], B[N];
int len(int x) {
int bits = 0, can = 1;
while (can < x) can *= 10, bits++;
return bits;
}
int check(int a, int b) {
unordered_map<string, int> mp;
for (int i = 0; i < n; i++) {
mp[A[i].substr(0, a) + B[i].substr(0, b)]++;
}
int ans = 0;
for (auto& [x, y] : mp) {
ans = max(ans, len(y));
}
return ans;
}
void sol() {
cin >> n;
int mxlen_A = 6, mxlen_B = 6;
for (int i = 0; i < n; i++) {
cin >> A[i] >> B[i];
mxlen_A = min(mxlen_A, (int)A[i].size());
mxlen_B = min(mxlen_B, (int)B[i].size());
}
int a = 0, b = 0, c = 6, ans = 6;
for (int i = 0; i <= mxlen_A; i++) {
for (int j = 0; j <= mxlen_B && i + j <= 6; j++) {
int k = check(i, j);
if (i + j + k < ans) {
ans = i + j + k;
a = i;
b = j;
c = k;
}
}
}
cout << a << ' ' << b << ' ' << c << '\n';
}
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int T;
cin >> T;
while (T--) {
sol();
}
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 17ms
memory: 65832kb
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: 29ms
memory: 65940kb
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 0 0 5 0 1 1 1 0 2 1 1 1 2 0 1
result:
wrong answer Loginy nie moga byc puste! (test case 1)