답안 #321750

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
321750 2020-11-13T09:12:26 Z alextodoran Tenis (COCI20_tenis) C++17
50 / 110
1000 ms 2156 KB
/**
 ____ ____ ____ ____ ____
||a |||t |||o |||d |||o ||
||__|||__|||__|||__|||__||
|/__\|/__\|/__\|/__\|/__\|

**/

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const int N_MAX = 100002;

int n;

int a[N_MAX], b[N_MAX], c[N_MAX];

int apos[N_MAX], bpos[N_MAX], cpos[N_MAX];

int f (int x, int y)
{
    if(x > y)
        swap(x, y);
    return x * n + y;
}

int cnta, cntb, cntc;

int wins[N_MAX];

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> n;
    for(int i = 1; i <= n; i++)
    {
        cin >> a[i];
        apos[a[i]] = i;
    }
    for(int i = 1; i <= n; i++)
    {
        cin >> b[i];
        bpos[b[i]] = i;
    }
    for(int i = 1; i <= n; i++)
    {
        cin >> c[i];
        cpos[c[i]] = i;
    }
    for(int i = 1; i <= n; i++)
        for(int j = i + 1; j <= n; j++)
        {
            int fa = f(apos[i], apos[j]);
            int fb = f(bpos[i], bpos[j]);
            int fc = f(cpos[i], cpos[j]);
            int mi = min({fa, fb, fc});
            if(fa == mi)
            {
                cnta++;
                if(apos[i] < apos[j])
                    wins[i]++;
                else
                    wins[j]++;
            }
            else if(fb == mi)
            {
                cntb++;
                if(bpos[i] < bpos[j])
                    wins[i]++;
                else
                    wins[j]++;
            }
            else
            {
                cntc++;
                if(cpos[i] < cpos[j])
                    wins[i]++;
                else
                    wins[j]++;
            }
        }
    cout << cnta << " " << cntb << " " << cntc << "\n";
    for(int i = 1; i <= n; i++)
        cout << wins[i] << " ";
    cout << "\n";
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 492 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 492 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 72 ms 640 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 492 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 72 ms 640 KB Output is correct
5 Execution timed out 1094 ms 2156 KB Time limit exceeded
6 Halted 0 ms 0 KB -