답안 #366440

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
366440 2021-02-14T08:03:23 Z VEGAnn Tenis (COCI20_tenis) C++14
50 / 110
1000 ms 2156 KB
#include <bits/stdc++.h>
#define i2 array<int,2>
using namespace std;
const int N = 100100;
const int oo = 2e9;
int a[3][N], n, win[N], crt[3], loc[3][N];

void calc(int x, int y){
    i2 mn = {oo, oo};

    for (int j = 0; j < 3; j++)
        mn = min(mn, {min(loc[j][x], loc[j][y]), max(loc[j][x], loc[j][y])});

    for (int j = 0; j < 3; j++) {
        i2 cr = {min(loc[j][x], loc[j][y]), max(loc[j][x], loc[j][y])};

        if (mn == cr){
            if (loc[j][x] > loc[j][y])
                swap(x, y);

            win[x]++;
            crt[j]++;

            return;
        }
    }

}

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);

#ifdef _LOCAL
    freopen("in.txt","r",stdin);
#endif // _LOCAL

    cin >> n;

    for (int j = 0; j < 3; j++)
    for (int i = 1; i <= n; i++) {
        cin >> a[j][i];

        loc[j][a[j][i]] = i;
    }

    for (int i = 1; i <= n; i++)
    for (int j = i + 1; j <= n; j++)
        calc(i, j);

    for (int i = 0; i < 3; i++)
        cout << crt[i] << " ";
    cout << '\n';

    for (int i = 1; i <= n; i++)
        cout << win[i] << " ";

    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 145 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 145 ms 492 KB Output is correct
5 Execution timed out 1082 ms 2156 KB Time limit exceeded
6 Halted 0 ms 0 KB -