답안 #487448

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
487448 2021-11-15T14:52:30 Z inksamurai Tenis (COCI20_tenis) C++17
50 / 110
1000 ms 3340 KB
#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

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 208 KB Output is correct
2 Correct 0 ms 312 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 0 ms 312 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 115 ms 512 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 0 ms 312 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 115 ms 512 KB Output is correct
5 Execution timed out 1092 ms 3340 KB Time limit exceeded
6 Halted 0 ms 0 KB -