QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#165566 | #5499. Aliases | arseny_y# | WA | 78ms | 5256kb | C++23 | 1.8kb | 2023-09-05 19:21:52 | 2023-09-05 19:21:52 |
Judging History
answer
//I wrote this code 4 u today
#include <bits/stdc++.h>
template<class t> using vc = std::vector<t>;
#define nd node*
#define pnd pair<nd, nd>
typedef long long ll;
template<const ll MOD>
struct mod_mul : std::multiplies<const ll> {
ll operator()(const ll a, const ll b) {
return (a * b) % MOD;
}
};
template<typename T>
inline void sort(T &a) {
std::sort(a.begin(), a.end());
}
template<typename T>
inline void unique(T &a) {
a.resize(std::unique(a.begin(), a.end()) - a.begin());
}
template<typename T>
inline void reverse(T &a) {
std::reverse(a.begin(), a.end());
}
const ll INF = 9023372036854775808ll;
const ll MOD = 1000000007ll;
using namespace std;
int main() {
std::cin.tie(nullptr)->ios_base::sync_with_stdio(false);
int z;
cin >> z;
while (z--) {
int n;
cin >> n;
vc<pair<string, string>> z(n);
for (auto &i: z) cin >> i.first >> i.second;
array<int, 4> ans = {(int) 1e9, 0, 0, 0};
for (int a = 0; a <= 10; ++a) {
for (int b = 0; b + a <= 10; ++b) {
unordered_map<string, int> cnt;
for (int i = 0; i < n; ++i) {
string nw;
for (int j = 0; j < z[i].first.size() && j < a; ++j) nw.push_back(z[i].first[j]);
for (int j = 0; j < z[i].second.size() && j < b; ++j) nw.push_back(z[i].second[j]);
cnt[nw]++;
}
int mx = -1;
for (auto &[x, y]: cnt) mx = max(mx, y);
int w = 0, nw = 1;
while (nw < mx) nw *= 10, ++w;
ans = min(array<int, 4>{a + b + w, a, b, w}, ans);
}
}
cout << ans[1] << ' ' << ans[2] << ' ' << ans[3] << '\n';
}
}
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 3636kb
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: 78ms
memory: 5256kb
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)