# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
852427 |
2023-09-21T19:21:53 Z |
dead0ne |
Tenis (COCI20_tenis) |
C++17 |
|
99 ms |
21944 KB |
#pragma GCC optimize("unroll-loops,Ofast,O3")
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define spc << " " <<
#define endl "\n"
#define all(x) x.begin(), x.end()
#define ll long long
#define int long long
#define ii pair<int,int>
#define vi vector<int>
#define vii vector<ii>
#define st first
#define nd second
#define inf 1000000009
#define MOD 1000000007
using namespace std;
void solve(){
int n; cin >> n;
vi firs[n+1];
int cour[n+1], win[n+1], win2[n+1];
vii seen[n+1];
int ans[4];
int wow[4][n+1];
memset(ans, 0, sizeof(ans));
for(int i=1; i<=n; i++){
win[i]=win2[i]=0;
}
for(int j=1; j<=3; j++){
for(int i=1; i<=n; i++){
int a; cin >> a;
seen[a].pb({i, j});
wow[j][a] = i;
}
}
for(int i=1; i<=n; i++){
sort(all(seen[i]));
cour[i] = seen[i][0].nd;
firs[seen[i][0].st].pb(i);
}
/*for(int i=1; i<=n; i++){
cerr << "**" spc i spc "**" << endl;
for(auto j:firs[i]) cerr << j << " ";
cerr << endl;
cerr << cour[i] << endl;
}*/
int cur=n;
for(int i=1; i<=n; i++){
//cerr << "**" spc i spc "**" << endl;
cur-=firs[i].size();
for(auto j:firs[i]) win[j]+=cur;
for(int j=0; j<firs[i].size(); j++){
for(int k=j+1; k<firs[i].size(); k++){
int ab = firs[i][j], ba = firs[i][k];
vii hehe;
for(int gu=1; gu<=3; gu++){
if(wow[gu][ab]==i){
hehe.pb({wow[gu][ba], gu});
}
else if(wow[gu][ba]==i){
hehe.pb({wow[gu][ab], gu});
}
}
sort(all(hehe));
if(wow[hehe[0].nd][ab]==i){
win2[ab]++;
ans[hehe[0].nd]++;
}
else if(wow[hehe[0].nd][ba]==i){
win2[ba]++;
ans[hehe[0].nd]++;
}
}
}
}
for(int i=1; i<=n; i++) ans[cour[i]]+=win[i];
cout << ans[1] spc ans[2] spc ans[3] << endl;
for(int i=1; i<=n; i++) cout << win[i]+win2[i] << " ";
}
signed main(){
ios_base::sync_with_stdio(false);cin.tie(0);
#ifdef Local
freopen("in","r",stdin);
freopen("out","w",stdout);
#endif
ll t=1;
//cin >> t;
while(t--) solve();
}
Compilation message
tenis.cpp: In function 'void solve()':
tenis.cpp:65:23: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
65 | for(int j=0; j<firs[i].size(); j++){
| ~^~~~~~~~~~~~~~~
tenis.cpp:66:29: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
66 | for(int k=j+1; k<firs[i].size(); k++){
| ~^~~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Partially correct |
0 ms |
348 KB |
Partially correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Partially correct |
0 ms |
348 KB |
Partially correct |
4 |
Correct |
2 ms |
1116 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Partially correct |
0 ms |
348 KB |
Partially correct |
4 |
Correct |
2 ms |
1116 KB |
Output is correct |
5 |
Partially correct |
32 ms |
8796 KB |
Partially correct |
6 |
Correct |
60 ms |
12884 KB |
Output is correct |
7 |
Partially correct |
65 ms |
16992 KB |
Partially correct |
8 |
Partially correct |
92 ms |
21404 KB |
Partially correct |
9 |
Partially correct |
83 ms |
20472 KB |
Partially correct |
10 |
Partially correct |
99 ms |
21944 KB |
Partially correct |