# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
928669 |
2024-02-17T01:20:23 Z |
NK_ |
Tenis (COCI20_tenis) |
C++17 |
|
41 ms |
10204 KB |
// Success consists of going from failure to failure without loss of enthusiasm
#include <bits/stdc++.h>
using namespace std;
#define nl '\n'
#define pb push_back
using ll = long long;
template<class T> using V = vector<T>;
using vi = V<int>;
using vl = V<ll>;
int main() {
cin.tie(0)->sync_with_stdio(0);
int N; cin >> N;
V<vi> A(3, vi(N));
for(int t = 0; t < 3; t++) {
for(int i = 0; i < N; i++) {
int x; cin >> x; --x; A[t][x] = N - 1 - i;
}
}
vi ord(N); iota(begin(ord), end(ord), 0);
V<vi> oc(N), C(8, vi(3));
for(int i = 0; i < N; i++) {
int mx = max({A[0][i], A[1][i], A[2][i]});
oc[mx].pb(i);
}
vl ans(N), amt(3);
for(int x = 0; x < N; x++) {
for(auto& i : oc[x]) {
// cout << x << " =====> " << i << endl;
int msk = 0;
for(int c = 0; c < 3; c++) if (A[c][i] == x) msk ^= (1 << c);
for(int sur = 0; sur < 3; sur++) {
ans[i] += C[msk][sur];
amt[sur] += C[msk][sur];
}
}
for(auto& i : oc[x]) {
for(auto& j : oc[x]) if (i < j) {
int best = 0;
for(int sur = 0; sur < 3; sur++) {
int bw = max(A[best][i], A[best][j]), bl = min(A[best][i], A[best][j]);
int sw = max(A[sur][i], A[sur][j]), sl = min(A[sur][i], A[sur][j]);
if (bw < sw) best = sur;
if (bw == sw && bl < sl) best = sur;
}
// cout << i << " VS " << j << " => " << best << endl;
amt[best]++;
if (A[best][i] > A[best][j]) ans[i]++;
else ans[j]++;
}
for(int m = 1; m < 8; m++) {
int mx = 0; for(int b = 0; b < 3; b++) if ((m >> b) & 1) mx = max(mx, A[b][i]);
int opt = 10; for(int b = 0; b < 3; b++) if ((m >> b) & 1) {
if (mx == A[b][i]) opt = min(opt, b);
}
// cout << i << " " << m << " => " << opt << endl;
C[m][opt]++;
}
}
}
for(auto& x : amt) cout << x << " ";
cout << nl;
for(auto& x : ans) cout << x << " ";
cout << nl;
exit(0-0);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
2 ms |
600 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
2 ms |
600 KB |
Output is correct |
5 |
Correct |
16 ms |
3772 KB |
Output is correct |
6 |
Correct |
24 ms |
5628 KB |
Output is correct |
7 |
Correct |
32 ms |
7192 KB |
Output is correct |
8 |
Correct |
41 ms |
9112 KB |
Output is correct |
9 |
Correct |
37 ms |
8912 KB |
Output is correct |
10 |
Correct |
36 ms |
10204 KB |
Output is correct |