Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- #include <vector>
- #include <limits.h>
- #include <map>
- #include <unordered_map>
- #include <set>
- #include <unordered_set>
- #include <string>
- #include <algorithm>
- #include <iomanip>
- #include <random>
- #include <time.h>
- #include <bitset>
- #include <queue>
- #include <deque>
- using namespace std;
- typedef long long ll;
- typedef unsigned long long ull;
- typedef long double ld;
- #define all(x) (x).begin(),(x).end()
- #define sz(x) (int)x.size()
- int main() {
- ios_base::sync_with_stdio(0);
- cin.tie(0); cout.tie(0);
- int n;
- cin >> n;
- vector<int> a[3];
- for (int i = 0; i < 3; ++i) {
- a[i].resize(n);
- for (int j = 0; j < n; ++j) {
- int pos;
- cin >> pos;
- --pos;
- a[i][pos] = j;
- }
- }
- int cnt[3];
- cnt[0] = cnt[1] = cnt[2] = 0;
- vector<vector<int>> comp(n, vector<int>(n, -1));
- for (int f = 0; f < n - 1; ++f) {
- for (int s = f + 1; s < n; ++s) {
- int mnf = min(a[0][f], min(a[1][f], a[2][f]));
- int mns = min(a[0][s], min(a[1][s], a[2][s]));
- if (mnf < mns) {
- int pos = 0;
- for (int i = 0; i < 3; ++i) {
- if (a[i][f] == mnf && a[pos][f] != mnf) {
- pos = i;
- }
- if (a[i][f] == mnf && a[i][s] < a[pos][s]) {
- pos = i;
- }
- }
- comp[f][s] = comp[s][f] = pos;
- ++cnt[pos];
- }
- else if (mns < mnf) {
- int pos = 0;
- for (int i = 0; i < 3; ++i) {
- if (a[i][s] == mns && a[pos][s] != mns) {
- pos = i;
- }
- if (a[i][s] == mns && a[i][f] < a[pos][f]) {
- pos = i;
- }
- }
- comp[f][s] = comp[s][f] = pos;
- ++cnt[pos];
- }
- else {
- if (a[0][f] == mnf && a[0][s] == mnf) {
- comp[f][s] = comp[s][f] = 0;
- ++cnt[0];
- }
- else if (a[1][f] == mnf && a[1][s] == mnf) {
- comp[f][s] = comp[s][f] = 1;
- ++cnt[1];
- }
- else if (a[2][f] == mnf && a[2][s] == mnf) {
- comp[f][s] = comp[s][f] = 2;
- ++cnt[2];
- }
- else {
- int pos = 0;
- for (int i = 0; i < 3; ++i) {
- if (min(a[i][f], a[i][s]) == mnf) {
- if (min(a[pos][f], a[pos][s]) != mnf) {
- pos = i;
- }
- if (max(a[i][f], a[i][s]) < max(a[pos][f], a[pos][s])) {
- pos = i;
- }
- }
- }
- comp[f][s] = comp[s][f] = pos;
- ++cnt[pos];
- }
- }
- }
- }
- cout << cnt[0] << " " << cnt[1] << " " << cnt[2] << "\n";
- vector<int> vic(n, 0);
- for (int i = 0; i < n; ++i) {
- for (int j = i + 1; j < n; ++j) {
- if (i == j) continue;
- if (a[comp[i][j]][i] < a[comp[i][j]][j]) {
- ++vic[i];
- }
- else {
- ++vic[j];
- }
- }
- }
- for (int i : vic) {
- cout << i << " ";
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement