답안 #512237

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
512237 2022-01-16T08:07:52 Z KoD Tenis (COCI20_tenis) C++17
55 / 110
48 ms 5456 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 << play[i] << " \n"[i + 1 == 3];
    }
    for (int i = 0; i < N; ++i) {
        std::cout << win[i] << " \n"[i + 1 == N];
    }
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 308 KB Output is correct
3 Partially correct 1 ms 204 KB Partially correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 308 KB Output is correct
3 Partially correct 1 ms 204 KB Partially correct
4 Correct 1 ms 332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 308 KB Output is correct
3 Partially correct 1 ms 204 KB Partially correct
4 Correct 1 ms 332 KB Output is correct
5 Partially correct 15 ms 2244 KB Partially correct
6 Correct 22 ms 3312 KB Output is correct
7 Partially correct 35 ms 4364 KB Partially correct
8 Partially correct 48 ms 5456 KB Partially correct
9 Partially correct 37 ms 5344 KB Partially correct
10 Partially correct 36 ms 5436 KB Partially correct