-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathA_Circle_Coloring.cpp
More file actions
49 lines (45 loc) · 1.17 KB
/
A_Circle_Coloring.cpp
File metadata and controls
49 lines (45 loc) · 1.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# include <bits/stdc++.h>
using namespace std;
int main(){
int testCases , n ;
cin >> testCases ;
while(testCases--){
cin >> n ;
int a[n] , b[n] , c[n] , p[n];
for(int i = 0 ; i<n ; i++){
cin >> a[i] ;
}
for(int i = 0 ; i<n ; i++){
cin >> b[i] ;
}
for(int i = 0 ; i<n ; i++){
cin >> c[i] ;
}
p[0] = a[0] ;
cout << p[0] << " " ;
for(int i = 1 ; i<n-1 ; i++){
if(a[i] == p[i-1]){
p[i] = b[i] ;
cout << p[i] << " " ;
}
else {
p[i] = a[i] ;
cout << p[i] << " " ;
}
}
if((a[n-1] != p[0]) && (p[n-2]!=a[n-1])){
p[n-1] = a[n-1];
cout << p[n-1] << " ";
}
else if((b[n-1] != p[0]) && (p[n-2]!=b[n-1])){
p[n-1] = b[n-1];
cout << p[n-1] << " ";
}
else if((c[n-1] != p[0]) && (p[n-2]!=c[n-1])){
p[n-1] = c[n-1];
cout << p[n-1] << " ";
}
cout << "\n" ;
}
return 0;
}