This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
const int man = (int)(1e5 + 500);
int n;
int winPlayer[man], courts[man];
int a[3][man], loc[3][man];
int main() {
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cin >> n;
for (int t = 0; t < 3; ++t) {
for (int i = 0; i < n; ++i) {
cin >> a[t][i];
--a[t][i];
loc[t][a[t][i]] = i;
}
}
cerr << "\n";
for (int i = 0; i < n; ++i) {
for (int j = (i + 1); j < n; ++j) {
int mnWin = n;
for (int t = 0; t < 3; ++t) {
mnWin = min(mnWin, min(loc[t][i], loc[t][j]));
}
int cnt = 0;
bool f1 = false, f2 = false;
for (int t = 0; t < 3; ++t) {
if (mnWin == loc[t][i]) {
f1 = true;
}
if (mnWin == loc[t][j]) {
f2 = true;
}
}
cnt = (f1 + f2);
if (cnt == 1) {
for (int t = 0; t < 3; ++t) {
if (mnWin == loc[t][i]) {
++winPlayer[i];
++courts[t];
break;
}
if (mnWin == loc[t][j]) {
++winPlayer[j];
++courts[t];
break;
}
}
} else {
int mnLose = n;
for (int t = 0; t < 3; ++t) {
if (mnWin == loc[t][i]) {
mnLose = min(mnLose, loc[t][j]);
}
if (mnWin == loc[t][j]) {
mnLose = min(mnLose, loc[t][i]);
}
}
int lst = -1;
cnt = 0;
f1 = false; f2 = false;
for (int t = 0; t < 3; ++t) {
if ((mnWin == loc[t][i]) && (mnLose == loc[t][j])) {
f1 = true;
if (lst == -1) {
lst = t;
}
}
if ((mnWin == loc[t][j]) && (mnLose == loc[t][i])) {
f2 = true;
if (lst == -1) {
lst = t;
}
}
}
assert(lst != -1); // assert
cnt = (f1 + f2);
if (cnt == 1) {
for (int t = 0; t < 3; ++t) {
if ((mnWin == loc[t][i]) && (mnLose == loc[t][j])) {
++courts[t];
++winPlayer[i];
break;
}
if ((mnWin == loc[t][j]) && (mnLose == loc[t][i])) {
++courts[t];
++winPlayer[j];
break;
}
}
} else {
++courts[lst];
if (loc[lst][i] == mnWin) {
++winPlayer[i];
} else {
++winPlayer[j];
}
}
}
}
}
for (int i = 0; i < 3; ++i) {
cout << courts[i] << " ";
}
cout << "\n";
for (int i = 0; i < n; ++i) {
cout << winPlayer[i] << " ";
}
cout << "\n";
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |