Submission #487448

#TimeUsernameProblemLanguageResultExecution timeMemory
487448inksamuraiTenis (COCI20_tenis)C++17
50 / 110
1092 ms3340 KiB
#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(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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...