A. Circle Coloring (Thinking)

https://codeforces.com/contest/1408/problem/A


I started to read the wrong question, and then found that the adjacent numbers are not equal, pay attention to the beginning and the end. And the title is also given to each ai, bi, ci that are not equal to each other, then there must be conditions to satisfy the title. Directly enumerate and judge whether the left and right neighbors are different, and pay attention to the situation at the beginning and the end.

#include<iostream>
#include<vector>
#include<queue>
#include<cstring>
#include<cmath>
#include<map>
#include<set>
#include<cstdio>
#include<algorithm>
#define debug(a) cout<<#a<<"="<<a<<endl;
using namespace std;
const int maxn=110;
typedef int LL;
LL a[maxn],b[maxn],c[maxn],p[maxn];
int main(void)
{
  cin.tie(0);std::ios::sync_with_stdio(false);
  LL t;cin>>t;
  while(t--)
  {
  	LL n;cin>>n;
  	for(LL i=0;i<=n+10;i++) a[i]=b[i]=c[i]=p[i]=0;
  	for(LL i=1;i<=n;i++) cin>>a[i];
  	for(LL i=1;i<=n;i++) cin>>b[i];
  	for(LL i=1;i<=n;i++) cin>>c[i];
  	for(LL i=1;i<=n;i++){
  		if(i==n){
  			if(a[i]!=p[1]&&a[i]!=p[i-1]) p[i]=a[i];
  			else if(b[i]!=p[1]&&b[i]!=p[i-1]) p[i]=b[i];
  			else if(c[i]!=p[1]&&c[i]!=p[i-1]) p[i]=c[i];
		}
		else if(a[i]!=p[i-1]) p[i]=a[i];
		else if(b[i]!=p[i-1]) p[i]=b[i];
		else if(c[i]!=p[i-1]) p[i]=c[i];
	}
	for(LL i=1;i<=n;i++) cout<<p[i]<<" ";
	cout<<endl;
  }
return 0;
}

 

Guess you like

Origin blog.csdn.net/zstuyyyyccccbbbb/article/details/108897586