/*
* ## ##### #### #### # # ####
* # # # # # # # # # # # #
* # # ##### # # # # # # #
* ###### # # # # # # ## # # #
* # # # # # # # # ## ## # #
* # # ##### #### #### # # ####
*/
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define pii pair <int, int>
#define X first
#define Y second
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define info() cerr << __PRETTY_FUNCTION__ << ": " << __LINE__ << endl
void abc() {cerr << endl;}
template <typename T, typename ...U> void abc(T a, U ...b) {
cerr << a << ' ', abc(b...);
}
template <typename T> void printv(T l, T r) {
while (l != r) cout << *l << " \n"[++l == r];
}
template <typename A, typename B> istream& operator >> (istream& o, pair<A, B> &a) {
return o >> a.X >> a.Y;
}
template <typename A, typename B> ostream& operator << (ostream& o, pair<A, B> a) {
return o << '(' << a.X << ", " << a.Y << ')';
}
template <typename T> ostream& operator << (ostream& o, vector<T> a) {
bool is = false;
for (T i : a) {o << (is ? ' ' : '{'), is = true, o << i;}
return o << '}';
}
template <typename T> struct vv : vector <vector <T>> {
vv(int n, int m, T v) : vector <vector <T>> (n, vector <T>(m, v)) {}
vv() {}
};
template <typename T> struct vvv : vector <vv <T>> {
vvv(int n, int m, int k, T v) : vector <vv <T>> (n, vv <T>(m, k, v)) {}
vvv() {}
};
#ifdef Doludu
#define test(args...) info(), abc("[" + string(#args) + "]", args)
#define owo void(0)
#else
#define test(args...) void(0)
#define owo ios::sync_with_stdio(false); cin.tie(0)
#endif
const int mod = 1e9 + 7, N = 200001, logN = 18, K = 1000;
struct court {
int mx1, mx2, id;
bool operator < (const court &o) {
if (mx1 != o.mx1) return mx1 < o.mx1;
if (mx2 != o.mx2) return mx2 < o.mx2;
return id < o.id;
}
};
int main () {
owo;
int n;
cin >> n;
vv <int> a(n, 3, 0), b(n, 3, 0);
for (int j = 0; j < 3; ++j) for (int i = 0; i < n; ++i) {
cin >> a[i][j], --a[i][j];
b[a[i][j]][j] = i;
}
vector <lli> held(3, 0), win(n, 0);
auto vs = [&](int i, int j) {
court tmp = {min(b[i][0], b[j][0]), max(b[i][0], b[j][0]), 0};
for (int k = 1; k < 3; ++k) {
court A = {min(b[i][k], b[j][k]), max(b[i][k], b[j][k]), k};
if (A < tmp) tmp = A;
}
held[tmp.id]++;
if (b[i][tmp.id] < b[j][tmp.id]) win[i]++;
else win[j]++;
};
vector <bool> vis(n, false);
int num = 0;
for (int i = 0; i < n; ++i) {
vector <int> cur;
for (int j = 0; j < 3; ++j) if (!vis[a[i][j]]) cur.pb(a[i][j]);
sort(all(cur));
cur.resize(unique(all(cur)) - cur.begin());
if (cur.size() == 2) vs(cur[0], cur[1]);
if (cur.size() == 3) {
vs(cur[0], cur[1]);
vs(cur[0], cur[2]);
vs(cur[1], cur[2]);
}
num += cur.size();
for (int j = 0; j < 3; ++j) if (!vis[a[i][j]]) {
held[j] += n - num;
win[a[i][j]] += n - num;
vis[a[i][j]] = true;
}
}
printv(all(held));
printv(all(win));
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Partially correct |
1 ms |
332 KB |
Partially correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Partially correct |
1 ms |
332 KB |
Partially correct |
4 |
Correct |
3 ms |
588 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Partially correct |
1 ms |
332 KB |
Partially correct |
4 |
Correct |
3 ms |
588 KB |
Output is correct |
5 |
Partially correct |
33 ms |
5224 KB |
Partially correct |
6 |
Correct |
52 ms |
7656 KB |
Output is correct |
7 |
Partially correct |
63 ms |
10108 KB |
Partially correct |
8 |
Partially correct |
108 ms |
12532 KB |
Partially correct |
9 |
Partially correct |
107 ms |
12560 KB |
Partially correct |
10 |
Partially correct |
110 ms |
12548 KB |
Partially correct |