Submission #358425

#TimeUsernameProblemLanguageResultExecution timeMemory
358425egekabasTenis (COCI20_tenis)C++14
80 / 110
218 ms13804 KiB
#include <bits/stdc++.h> #define all(x) (x).begin(), (x).end() #define ff first #define ss second #define pb push_back #define mp make_pair using namespace std; typedef long long ll; typedef unsigned long long ull; typedef long double ld; typedef pair<int, int> pll; typedef pair<ull, ull> pull; typedef pair<int, int> pii; typedef pair<ld, ld> pld; vector<vector<int>> a; int n; int play[100009]; int court[100009]; void manual(int x, int y){ vector<vector<int>> rnk; for(int i = 0; i < 3; ++i){ rnk.pb({min(a[x][i], a[y][i]), max(a[x][i], a[y][i]), i}); } sort(all(rnk)); int cur = rnk[0][2]; court[cur]++; if(a[x][cur] < a[y][cur]) ++play[x]; else ++play[y]; } vector<int> best[100009]; int dp[(1<<3)][3]; int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); //freopen("in.txt", "r", stdin); //freopen("out.txt", "w", stdout); cin >> n; a = vector<vector<int>> (n, vector<int>(3)); for(int i = 0; i < 3; ++i) for(int j = 0; j < n; ++j){ int idx; cin >> idx; a[idx-1][i] = j; } for(int i = 0; i < n; ++i){ int mini = 1e9; for(auto u : a[i]) mini = min(mini, u); best[mini].pb(i); } for(int i = n-1; i >= 0; --i){ for(auto idx : best[i]){ int st = 0; for(int j = 0; j < 3; ++j) if(a[idx][j] == i) st += (1<<j); for(int j = 0; j < 3; ++j){ play[idx] += dp[st][j]; court[j] += dp[st][j]; } } for(int j = 0; j < best[i].size(); ++j) for(int k = j+1; k < best[i].size(); ++k) manual(best[i][j], best[i][k]); for(auto idx : best[i]){ for(int st = 1; st < (1<<3); ++st){ vector<pii> rnk; for(int j = 0; j < 3; ++j) if(st&(1<<j)) rnk.pb({a[idx][j], j}); sort(all(rnk)); dp[st][rnk[0].ss]++; } } } cout << court[0] << ' ' << court[1] << ' ' << court[2] << '\n'; for(int i = 0; i < n; ++i) cout << play[i] << ' '; }

Compilation message (stderr)

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