Submission #366518

#TimeUsernameProblemLanguageResultExecution timeMemory
366518VimmerTenis (COCI20_tenis)C++14
0 / 110
1 ms364 KiB
#include <bits/stdc++.h> //#include <ext/pb_ds/assoc_container.hpp> //#include <ext/pb_ds/tree_policy.hpp> //#pragma GCC optimize("-O3") //#pragma GCC optimize("unroll-loops") //#pragma GCC optimize("-Ofast") #define N 200500 #define NN 205000 #define PB push_back #define endl '\n' #define pri(x) cout << x << endl #define _ << " " << #define all(x) x.begin(), x.end() #define sz(x) int(x.size()) #define M ll(1e9 + 7) #define F first #define S second using namespace std; //using namespace __gnu_pbds; typedef long long ll; typedef long double ld; typedef short int si; typedef unsigned long long ull; //typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set; int pos[3][N], ans[N], kol[3]; int men(int x) { int mn = 1e9; for (int i = 0; i < 3; i++) mn = min(mn, pos[i][x]); return mn; } int kl(int x) { int t = men(x), ans = 0; for (int i = 0; i < 3; i++) if (pos[i][x] == t) ans++; return ans; } int main() { ios_base::sync_with_stdio(0); istream::sync_with_stdio(0); cin.tie(0); cout.tie(0); // freopen("1.in", "r", stdin); int n; cin >> n; for (int i = 0; i < 3; i++) { for (int j = 0; j < n; j++) { int t; cin >> t; t--; pos[i][t] = j; } } for (int i = 0; i < n; i++) for (int j = i + 1; j < n; j++) { int k1 = 0, k2 = 0; for (int t = 0; t < 3; t++) if (pos[t][i] > pos[t][j]) k2++; else k1++; if (k1 > k2) { ans[i]++; if (kl(i) == 1) { int mnr = men(i); for (int t = 0; t < 3; t++) { if (pos[t][i] == mnr) { kol[t]++; } } } else { int mnr = men(j); for (int t = 0; t < 3; t++) { if (pos[t][j] == mnr) { kol[t]++; break; } } } } else { ans[j]++; if (kl(j) == 1) { int mnr = men(j); for (int t = 0; t < 3; t++) { if (pos[t][j] == mnr) { kol[t]++; } } } else { int mnr = men(i); for (int t = 0; t < 3; t++) { if (pos[t][i] == mnr) { kol[t]++; break; } } } } } for (int i = 0; i < 3; i++) cout << kol[i] << " "; cout << endl; for (int i = 0; i < n; i++) cout << ans[i] << " "; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...