// #pragma GCC target ("avx,avx2,fma")
// #pragma GCC optimize ("Ofast,inline") // O1 - O2 - O3 - Os - Ofast
// #pragma GCC optimize ("unroll-loops")
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for (int i = (a); i < (b); ++i)
#define per(i, a, b) for (int i = (b - 1); i >= (a); --i)
#define trav(a, x) for (auto &a : x)
#define all(x) x.begin(), x.end()
#define sz(x) x.size()
#define pb push_back
#define debug(x) cout << #x << " = " << x << endl
#define umap unordered_map
#define uset unordered_set
typedef pair<int, int> ii;
typedef pair<int, ii> iii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef long long ll;
typedef pair<ll, ll> pll;
typedef vector<ll> vll;
typedef vector<pll> vpll;
const int INF = 1'000'000'007;
int main() {
cin.tie(0)->sync_with_stdio(0);
cin.exceptions(cin.failbit);
ll n, people[100001][3], wins[100001], courts[3], best_court[100001];
memset(courts, 0, sizeof(courts));
memset(wins, 0, sizeof(wins));
vll best[100001];
cin >> n;
rep(i, 0, 3) rep(j, 0, n) {
ll person;
cin >> person;
people[person - 1][i] = j;
}
rep(i, 0, n) {
ll mn = n;
rep(j, 0, 3) if (people[i][j] < mn) {
mn = people[i][j];
best_court[i] = j;
}
best[mn].pb(i);
}
ll cnt = n;
rep(i, 0, n) {
cnt -= ll(sz(best[i]));
trav(person, best[i]) {
wins[person] += cnt;
courts[best_court[person]] += cnt;
}
rep(j, 0, ll(sz(best[i])) - 1) {
rep(k, j + 1, ll(sz(best[i]))) {
ll p1 = best[i][j], p2 = best[i][k];
assert(best_court[p1] != best_court[p2]);
ll best1 = best_court[p1], best2 = best_court[p2];
ll val1 = people[p1][best2], val2 = people[p2][best1];
if (val1 < val2 || (val1 == val2 && best2 < best1)) {
++wins[p2];
++courts[best2];
} else {
++wins[p1];
++courts[best1];
}
}
}
}
rep(i, 0, 3) cout << courts[i] << ' ';
cout << endl;
rep(i, 0, n) cout << wins[i] << ' ';
cout << endl;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
6476 KB |
Output is correct |
2 |
Correct |
3 ms |
6476 KB |
Output is correct |
3 |
Partially correct |
3 ms |
6572 KB |
Partially correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
6476 KB |
Output is correct |
2 |
Correct |
3 ms |
6476 KB |
Output is correct |
3 |
Partially correct |
3 ms |
6572 KB |
Partially correct |
4 |
Correct |
5 ms |
6584 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
6476 KB |
Output is correct |
2 |
Correct |
3 ms |
6476 KB |
Output is correct |
3 |
Partially correct |
3 ms |
6572 KB |
Partially correct |
4 |
Correct |
5 ms |
6584 KB |
Output is correct |
5 |
Partially correct |
26 ms |
8208 KB |
Partially correct |
6 |
Correct |
30 ms |
9112 KB |
Output is correct |
7 |
Partially correct |
36 ms |
9876 KB |
Partially correct |
8 |
Partially correct |
48 ms |
10820 KB |
Partially correct |
9 |
Incorrect |
48 ms |
10464 KB |
Output isn't correct |
10 |
Halted |
0 ms |
0 KB |
- |