Submission #489623

#TimeUsernameProblemLanguageResultExecution timeMemory
489623VictorTenis (COCI20_tenis)C++17
25 / 110
48 ms10820 KiB
// #pragma GCC target ("avx,avx2,fma") // #pragma GCC optimize ("Ofast,inline") // O1 - O2 - O3 - Os - Ofast // #pragma GCC optimize ("unroll-loops") #include <bits/stdc++.h> using namespace std; #define rep(i, a, b) for (int i = (a); i < (b); ++i) #define per(i, a, b) for (int i = (b - 1); i >= (a); --i) #define trav(a, x) for (auto &a : x) #define all(x) x.begin(), x.end() #define sz(x) x.size() #define pb push_back #define debug(x) cout << #x << " = " << x << endl #define umap unordered_map #define uset unordered_set typedef pair<int, int> ii; typedef pair<int, ii> iii; typedef vector<int> vi; typedef vector<ii> vii; typedef vector<vi> vvi; typedef long long ll; typedef pair<ll, ll> pll; typedef vector<ll> vll; typedef vector<pll> vpll; const int INF = 1'000'000'007; int main() { cin.tie(0)->sync_with_stdio(0); cin.exceptions(cin.failbit); ll n, people[100001][3], wins[100001], courts[3], best_court[100001]; memset(courts, 0, sizeof(courts)); memset(wins, 0, sizeof(wins)); vll best[100001]; cin >> n; rep(i, 0, 3) rep(j, 0, n) { ll person; cin >> person; people[person - 1][i] = j; } rep(i, 0, n) { ll mn = n; rep(j, 0, 3) if (people[i][j] < mn) { mn = people[i][j]; best_court[i] = j; } best[mn].pb(i); } ll cnt = n; rep(i, 0, n) { cnt -= ll(sz(best[i])); trav(person, best[i]) { wins[person] += cnt; courts[best_court[person]] += cnt; } rep(j, 0, ll(sz(best[i])) - 1) { rep(k, j + 1, ll(sz(best[i]))) { ll p1 = best[i][j], p2 = best[i][k]; assert(best_court[p1] != best_court[p2]); ll best1 = best_court[p1], best2 = best_court[p2]; ll val1 = people[p1][best2], val2 = people[p2][best1]; if (val1 < val2 || (val1 == val2 && best2 < best1)) { ++wins[p2]; ++courts[best2]; } else { ++wins[p1]; ++courts[best1]; } } } } rep(i, 0, 3) cout << courts[i] << ' '; cout << endl; rep(i, 0, n) cout << wins[i] << ' '; cout << endl; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...