답안 #445823

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
445823 2021-07-19T19:29:24 Z Jasiekstrz Tenis (COCI20_tenis) C++17
0 / 110
0 ms 332 KB
#include<bits/stdc++.h>
#define fi first
#define se second
using namespace std;
const int N=1e5;
int tab[N+10][3];
int srt[N+10];
int ans[3];
int win[N+10];
int ww[3][3];
int www[3];
int mn_pos(int x)
{
	return min({tab[x][0],tab[x][1],tab[x][2]});
}
void f(int a,int b)
{
	vector<tuple<int,int,int>> tmp;
	for(int i=0;i<3;i++)
		tmp.emplace_back(min(tab[a][i],tab[b][i]),max(tab[a][i],tab[b][i]),i);
	sort(tmp.begin(),tmp.end());
	int c=get<2>(tmp[0]);
	ans[c]++;
	if(tab[a][c]<tab[b][c])
		win[a]++;
	else
		win[b]++;
	return;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int n;
	cin>>n;
	for(int j=0;j<3;j++)
	{
		for(int i=1;i<=n;i++)
		{
			int x;
			cin>>x;
			tab[x][j]=i;
		}
	}
	for(int i=1;i<=n;i++)
		srt[i]=i;
	sort(srt+1,srt+n+1,[](int a,int b){ return mn_pos(a)>mn_pos(b); });
	for(int i=1;i<=n;i++)
	{
		for(int j=max(1,i-2);j<i;j++)
			f(i,j);
		if(i-2>0)
		{
			win[i]+=i-3;
			int mn=mn_pos(i);
			vector<int> win_pos;
			for(int j=0;j<3;j++)
			{
				if(tab[i][j]==mn)
					win_pos.push_back(j);
			}
			if(win_pos.size()==1)
				ans[win_pos[0]]+=i-3;
			else if(win_pos.size()==2)
			{
				ans[win_pos[0]]+=ww[win_pos[0]][win_pos[1]];
				ans[win_pos[1]]+=ww[win_pos[1]][win_pos[0]];
			}
			else
			{
				for(int j=0;j<3;j++)
					ans[win_pos[j]]+=www[win_pos[j]];
			}

			vector<pair<int,int>> xd(3);
			for(int j=0;j<3;j++)
				xd[j]={tab[i-2][j],j};
			sort(xd.begin(),xd.end());
			www[xd[0].se]++;
			int g[3];
			for(int j=0;j<3;j++)
				g[xd[j].se]=j;
			for(int a=0;a<3;a++)
			{
				for(int b=0;b<3;b++)
				{
					if(g[a]<g[b])
						ww[a][b]++;
				}
			}
		}
	}
	cout<<ans[0]<<" "<<ans[1]<<" "<<ans[2]<<"\n";
	for(int i=1;i<=n;i++)
		cout<<win[i]<<" \n"[i==n];
	return 0;
}

# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 332 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 332 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 332 KB Output isn't correct
2 Halted 0 ms 0 KB -