QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#77270 | #5499. Aliases | nweeks | WA | 78ms | 5132kb | C++17 | 1.5kb | 2023-02-13 21:09:30 | 2023-02-13 21:11:20 |
Judging History
answer
#include <bits/stdc++.h>
#define int long long
using namespace std;
string to_string(string s) { return s; }
template <typename T> string to_string(T v) {
bool first = true;
string res = "[";
for (const auto &x : v) {
if (!first)
res += ", ";
first = false;
res += to_string(x);
}
res += "]";
return res;
}
void dbg_out() { cout << endl; }
template <typename Head, typename... Tail> void dbg_out(Head H, Tail... T) {
cout << ' ' << to_string(H);
dbg_out(T...);
}
#ifdef DEBUG
#define dbg(...) cout << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__)
#else
#define dbg(...)
#endif
void solve() {
int N;
cin >> N;
vector<pair<string, string>> names(N);
for (auto &[s, t] : names)
cin >> s >> t;
int solA = 1e18, solB = 1e18, solC = 1e18;
for (int a = 0; a <= 6; ++a)
for (int b = 0; b <= 6 - a; ++b) {
map<string, int> cnt;
for (auto &[s, t] : names) {
cnt[s.substr(0, a) + t.substr(0, b)]++;
}
int c = 0;
int maxAllowed = 1;
for (auto &[s, x] : cnt) {
while (maxAllowed < x)
c++, maxAllowed *= 10;
}
if (solA + solB + solC > a + b + c)
solA = a, solB = b, solC = c;
}
cout << solA << ' ' << solB << ' ' << solC << '\n';
}
signed main(void) {
ios_base::sync_with_stdio(false);
cin.tie(0);
int nbTests;
cin >> nbTests;
for (int iTest(0); iTest < nbTests; ++iTest)
solve();
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3380kb
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: 5132kb
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)