#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define sz(a) (int)a.size()
#define all(a) a.begin(),a.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define crep(i,x,n) for(int i=x;i<n;i++)
#define drep(i,n) for(int i=n-1;i>=0;i--)
#define vec(...) vector<__VA_ARGS__>
#define _322ZVFH ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
using namespace std;
typedef long long ll;
typedef long double ld;
using pii=pair<int,int>;
using vi=vector<int>;
int main(){
_322ZVFH;
int n;
cin>>n;
vec(vi) a(n,vi(3));
rep(j,3)rep(i,n){
int x;
cin>>x;
x--;
a[x][j]=i+1;
}
auto gwin=[&](int i,int j)->pii{
int mna=1e9,mnab=1e9,ca=-1;
rep(t,3){
if(a[i][t]<mna){
mna=a[i][t];
mnab=a[j][t];
ca=t;
}else if(a[i][t]==mna){
if(a[j][t]<mnab){
mnab=a[j][t];
ca=t;
}
}
}
int mnb=1e9,mnba=1e9,cb=-1;
rep(t,3){
if(a[j][t]<mnb){
mnb=a[j][t];
mnba=a[i][t];
cb=t;
}else if(a[j][t]==mnb){
if(a[i][t]<mnba){
mnba=a[i][t];
cb=t;
}
}
}
pii p={-1,-1};
p=(mna<mnb?pii{mna,mnab}:mnb<mna?pii{mnb,mnba}:mnab<mnba?pii{mna,mnab}:pii{mnb,mnba});
int cnt=0,pans1=-1,pans2=-1;
rep(t,3){
if(a[i][t]==p.fi and a[j][t]==p.se){
if(pans1==-1){
pans1=t;
pans2=i;
}
}
if(a[j][t]==p.fi and a[i][t]==p.se){
if(pans2==-1){
pans1=t;
pans2=j;
}
}
}
return {pans1,pans2};
};
vi pans(3,0),ppans(n,0);
rep(i,n){
crep(j,i+1,n){
pii p=gwin(i,j);
pans[p.fi]++;
ppans[p.se]++;
}
}
rep(i,n){
int minima=*min_element(all(a[i]));
int cnt=count(all(a[i]),minima);
assert(cnt==1);
}
rep(t,3){
cout<<pans[t]<<" ";
}
cout<<"\n";
rep(i,n){
cout<<ppans[i]<<" ";
}
cout<<"\n";
//
return 0;
}
Compilation message
tenis.cpp: In lambda function:
tenis.cpp:30:24: warning: variable 'ca' set but not used [-Wunused-but-set-variable]
30 | int mna=1e9,mnab=1e9,ca=-1;
| ^~
tenis.cpp:43:24: warning: variable 'cb' set but not used [-Wunused-but-set-variable]
43 | int mnb=1e9,mnba=1e9,cb=-1;
| ^~
tenis.cpp:58:7: warning: unused variable 'cnt' [-Wunused-variable]
58 | int cnt=0,pans1=-1,pans2=-1;
| ^~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Runtime error |
2 ms |
460 KB |
Execution killed with signal 6 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Runtime error |
2 ms |
460 KB |
Execution killed with signal 6 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Runtime error |
2 ms |
460 KB |
Execution killed with signal 6 |