답안 #378925

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
378925 2021-03-17T07:39:03 Z NONAME Tenis (COCI20_tenis) C++17
50 / 110
1000 ms 2156 KB
#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;
            for (int t = 0; t < 3; ++t) {
                if (mnWin == loc[t][i]) {
                    ++cnt;
                }
                if (mnWin == loc[t][j]) {
                    ++cnt;
                }
            }

            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;
                for (int t = 0; t < 3; ++t) {
                    if ((mnWin == loc[t][i]) && (mnLose == loc[t][j])) {
                        ++cnt;
                        if (lst == -1) {
                            lst = t;
                        }
                    }
                    if ((mnWin == loc[t][j]) && (mnLose == loc[t][i])) {
                        ++cnt;
                        if (lst == -1) {
                            lst = t;
                        }
                    }
                }
                assert(lst != -1); // assert

                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;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 2 ms 364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 2 ms 364 KB Output is correct
4 Correct 102 ms 492 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 2 ms 364 KB Output is correct
4 Correct 102 ms 492 KB Output is correct
5 Execution timed out 1096 ms 2156 KB Time limit exceeded
6 Halted 0 ms 0 KB -