답안 #512238

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
512238 2022-01-16T08:09:30 Z KoD Tenis (COCI20_tenis) C++17
55 / 110
40 ms 3852 KB
#include <bits/stdc++.h>

using std::vector;
using std::array;
using std::pair;
using std::tuple;

template <class F> struct RecLambda : private F {
    explicit RecLambda(F&& f) : F(std::forward<F>(f)) {}
    template <class... Args> decltype(auto) operator()(Args&&... args) const {
        return F::operator()(*this, std::forward<Args>(args)...);
    }
};

int main() {
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(nullptr);
    int N;
    std::cin >> N;
    vector<array<int, 3>> order(N);
    vector<array<int, 3>> rank(N);
    for (int i = 0; i < 3; ++i) {
        for (int j = 0; j < N; ++j) {
            std::cin >> order[j][i];
            order[j][i] -= 1;
            rank[order[j][i]][i] = j;
        }
    }
    const auto court = [&](const int i, const int j) {
        tuple tup(N, N, 3);
        for (int k = 0; k < 3; ++k) {
            tup = std::min(tup, tuple(std::min(rank[i][k], rank[j][k]), std::max(rank[i][k], rank[j][k]), k));
        }
        return std::get<2>(tup);
    };
    array<long long, 3> play = {};
    vector<int> win(N);
    vector<char> done(N);
    int remain = N;
    for (int i = 0; i < N; ++i) {
        vector<pair<int, int>> buf;
        for (int j = 0; j < 3; ++j) {
            const int x = order[i][j];
            if (!done[x]) {
                done[x] = true;
                remain -= 1;
                buf.emplace_back(j, x);
            }
        }
        const int n = buf.size();
        for (int j = 0; j < n; ++j) {
            for (int k = 0; k < j; ++k) {
                const int x = buf[j].second, y = buf[k].second;
                const int l = court(x, y);
                play[l] += 1;
                win[rank[x][l] < rank[y][l] ? x : y] += 1;
            }
        }
        for (const auto& [j, x] : buf) {
            play[j] += remain;
            win[x] += remain;
        }
    }
    for (int i = 0; i < 3; ++i) {
        std::cout << 0 << " \n"[i + 1 == 3];
    }
    for (int i = 0; i < N; ++i) {
        std::cout << win[i] << " \n"[i + 1 == N];
    }
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Partially correct 1 ms 204 KB Partially correct
2 Partially correct 0 ms 204 KB Partially correct
3 Partially correct 0 ms 204 KB Partially correct
# 결과 실행 시간 메모리 Grader output
1 Partially correct 1 ms 204 KB Partially correct
2 Partially correct 0 ms 204 KB Partially correct
3 Partially correct 0 ms 204 KB Partially correct
4 Partially correct 2 ms 332 KB Partially correct
# 결과 실행 시간 메모리 Grader output
1 Partially correct 1 ms 204 KB Partially correct
2 Partially correct 0 ms 204 KB Partially correct
3 Partially correct 0 ms 204 KB Partially correct
4 Partially correct 2 ms 332 KB Partially correct
5 Partially correct 15 ms 1652 KB Partially correct
6 Partially correct 22 ms 2336 KB Partially correct
7 Partially correct 30 ms 3012 KB Partially correct
8 Partially correct 40 ms 3852 KB Partially correct
9 Partially correct 35 ms 3780 KB Partially correct
10 Partially correct 34 ms 3780 KB Partially correct