-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathA.cpp
47 lines (39 loc) · 1.03 KB
/
A.cpp
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
#include <bits/stdc++.h>
using namespace std;
#define nl '\n'
template<typename T_vector>
void output_vector(const T_vector &v, bool add_one = false, int start = -1, int end = -1) {
if (start < 0) start = 0;
if (end < 0) end = int(v.size());
for (int i = start; i < end; i++)
cout << v[i] + (add_one ? 1 : 0) << (i < end - 1 ? ' ' : '\n');
}
void run_cases() {
int n;
cin >> n;
vector<vector<int>> vals(3, vector<int>(n));
for(int i=0;i<3;i++) {
for(int j=0;j<n;j++) {
cin >> vals[i][j];
}
}
vector<int> ans(n, -1);
ans[0] = vals[0][0];
for(int i=1;i<n;i++) {
for(int j=0;j<3;j++) {
if(ans[i-1] != vals[j][i] && ans[i == n - 1 ? 0 : i + 1] != vals[j][i]) {
ans[i] = vals[j][i];
break;
}
}
}
output_vector(ans);
}
int main() {
ios_base::sync_with_stdio(0); cin.tie(nullptr);
int tests = 1;
cin >> tests;
for(int test = 1;test <= tests;test++) {
run_cases();
}
}