제출 #576200

#제출 시각아이디문제언어결과실행 시간메모리
576200eecsTenis (COCI20_tenis)C++17
110 / 110
302 ms24104 KiB
#include <bits/stdc++.h> using namespace std; const int maxn = 100010; int n, p[3][maxn], q[3][maxn], ans[maxn]; int num[8], pos[maxn], mask[maxn], foo[maxn][8]; long long cnt[3]; int main() { ios::sync_with_stdio(0), cin.tie(0); cin >> n; for (int i = 0; i < 3; i++) { for (int j = 1; j <= n; j++) { cin >> p[i][j], q[i][p[i][j]] = j; } } vector<array<int, 2>> V; for (int i = 1; i <= n; i++) { for (int j = 1; j < 8; j++) { array<int, 2> mn{INT_MAX, 0}; for (int k = 0; k < 3; k++) { if (j >> k & 1) mn = min(mn, array<int, 2>{q[k][i], k}); } foo[i][j] = mn[1]; } for (int j = 0; j < 3; j++) { if (q[j][i] == q[foo[i][7]][i]) mask[i] |= 1 << j; } V.push_back({q[foo[i][7]][i], i}); } sort(V.begin(), V.end()); for (int i = 0; i < V.size(); i++) { pos[V[i][1]] = i, ans[V[i][1]] = V.size() - i - 1; } for (auto &p : V) { for (int i = 1; i < 8; i++) cnt[foo[p[1]][i]] += num[i]; num[mask[p[1]]]++; } auto chk = [&](int i, int j) { static set<pair<int, int>> S; if (i > j) swap(i, j); if (i == j || S.count({i, j})) return; S.emplace(i, j); if (pos[i] > pos[j]) swap(i, j); ans[i]--, cnt[foo[j][mask[i]]]--; array<int, 3> res{INT_MAX, 0, 0}; for (int k = 0; k < 3; k++) { int x = q[k][i], y = q[k][j]; res = min(res, array<int, 3>{min(x, y), max(x, y), k}); } (q[res[2]][i] < q[res[2]][j] ? ans[i] : ans[j])++, cnt[res[2]]++; }; for (int i = 1; i <= n; i++) { chk(p[0][i], p[1][i]), chk(p[0][i], p[2][i]), chk(p[1][i], p[2][i]); } cout << cnt[0] << " " << cnt[1] << " " << cnt[2] << "\n"; for (int i = 1; i <= n; i++) { cout << ans[i] << " "; } return 0; }

컴파일 시 표준 에러 (stderr) 메시지

tenis.cpp: In function 'int main()':
tenis.cpp:32:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::array<int, 2> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   32 |     for (int i = 0; i < V.size(); i++) {
      |                     ~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...