QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#377500 | #5499. Aliases | 8BQube# | WA | 11ms | 5256kb | C++20 | 1.4kb | 2024-04-05 14:28:38 | 2024-04-05 14:28:39 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define X first
#define Y second
#define SZ(a) ((int)a.size())
#define pb push_back
#define ALL(v) v.begin(), v.end()
unordered_map<string, int> mp;
void solve() {
int mn = 6, sa = 0, sb = 0, sc = 6;
int n;
cin >> n;
vector<pair<string, string>> v(n);
for (int i = 0; i < n; i++)
cin >> v[i].X >> v[i].Y;
auto get = [&](const string &s, int x) {
if (SZ(s) <= x)
return s;
else
return s.substr(0, x);
};
for (int S = 0; S < 6 && S < mn; S++)
for (int a = 0; a < 6; a++)
for (int b = 0; b < 6; b++)
if (a + b == S) {
mp.clear();
for (int i = 0; i < n; i++) {
mp[get(v[i].X, a) + get(v[i].Y, b)] += 1;
}
int mx = 0;
for (auto p : mp)
mx = max(mx, p.Y);
int c = 0, cnt = 1;
while (cnt < mx)
c++, cnt *= 10;
if (a + b + c < mn)
sa = a, sb = b, sc = c, mn = a + b + c;
}
cout << sa << " " << sb << " " << sc << "\n";
}
int main() {
ios::sync_with_stdio(0), cin.tie(0);
int T;
cin >> T;
while (T--)
solve();
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3816kb
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: 11ms
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)