This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |