-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path1408A.cpp
More file actions
88 lines (86 loc) · 1.88 KB
/
1408A.cpp
File metadata and controls
88 lines (86 loc) · 1.88 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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#include <bits/stdc++.h>
#define mod 1000000007
#define FOR(i, a, b) for (i = a; i < b; i++)
#define FastIO \
ios_base::sync_with_stdio(false); \
cin.tie(NULL); \
cout.tie(NULL);
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
typedef priority_queue<ll, vector<ll>, greater<ll>> minheap;
typedef priority_queue<ll> maxheap;
int dxrow[] = {-1, 0, 0, 1, 1, 1, -1, -1}; //first 4 straight last 4 diagonals
int dycol[] = {0, -1, 1, 0, 1, -1, -1, 1};
void printV(vector<ll> v)
{
for (ll i = 0; i < v.size(); i++)
cout << v[i] << " ";
}
ll power(ll a, ll b)
{
return (ll)(pow(a, b) + 0.5);
}
int modexp(ll A, ll B, ll C)
{
if (A == 0)
return 0;
if (B == 0)
return 1;
ll y;
if (B % 2 == 0)
{
y = modexp(A, B / 2, C);
y = (y * y) % C;
}
else
{
y = A % C;
y = (y * modexp(A, B - 1, C) % C) % C;
}
return (ll)((y + C) % C);
}
int main()
{
ll t;
cin >> t;
while (t--)
{
ll n;
cin >> n;
ll a[n], b[n], c[n], i;
FOR(i, 0, n)
{
cin >> a[i];
}
FOR(i, 0, n)
{
cin >> b[i];
}
FOR(i, 0, n)
{
cin >> c[i];
}
vector<ll> ans = {a[0]};
ll x = 1;
while (x < n)
{
if (a[x] == ans[x - 1])
ans.push_back(b[x]);
else
ans.push_back(a[x]);
x++;
}
if (ans[0] == ans[n - 1])
{
if (a[n - 1] != ans[n - 2] && a[n - 1] != ans[0])
ans[n - 1] = a[n - 1];
else if (b[n - 1] != ans[n - 2] && b[n - 1] != ans[0])
ans[n - 1] = b[n - 1];
else
ans[n - 1] = c[n - 1];
}
printV(ans);
cout << '\n';
}
}