This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 (stderr)
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;
| ^~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |