清华题目

  • 时间:
  • 来源:互联网
  • 文章标签:


#include <stdio.h>
#include <string.h>
 
const int SZ = 1 << 20;  //提升IO buff 
struct fastio{
	char inbuf[SZ];
	char outbuf[SZ];
	fastio(){
		setvbuf(stdin, inbuf, _IOFBF, SZ);
		setvbuf(stdout, outbuf, _IOFBF, SZ);
	}
}io;
 
#define N 500001
int dp[4][N];
int mark[N]; // 0:未选  1:已选
char ret[N];
 
void team(int n, int *mark)
{
	int a = 1, b = 1, c = 1;
	int t;
	for (int i = 0; i < n; i++)
	{
		t = i % 3;
		switch (t)
		{
		case 0:
			while (mark[dp[t][a]] == 1) a++;
			mark[dp[t][a]] = 1;
			ret[dp[t][a]] = 'A';
			break;
		case 1:
			while (mark[dp[t][b]] == 1) b++;
			mark[dp[t][b]] = 1;
			ret[dp[t][b]] = 'B';
			break;
		case 2:
			while (mark[dp[t][c]] == 1) c++;
			mark[dp[t][c]] = 1;
			ret[dp[t][c]] = 'C';
			break;
		}
			
	}
}
 
int main()
{
	int n;
	int k;
	scanf("%d", &n);
 
	for (int i = 0; i < 3; i++)
	{
		for (int j = 1; j <= n; j++)
			scanf("%d", &dp[i][j]);
	}
	
	memset(mark, 0, n);
	team(n, mark);
	scanf("%d", &k);
	printf("%c\n", ret[k]);
 
	return 0;
}


本文链接http://www.taodudu.cc/news/show-1781743.html