-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcdfjan27q3.cpp
More file actions
53 lines (49 loc) · 1.13 KB
/
Copy pathcdfjan27q3.cpp
File metadata and controls
53 lines (49 loc) · 1.13 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
#include <iostream>
using namespace std;
int main()
{
int samples;
cin >> samples;
while (samples--)
{
int n;
cin >> n;
int input[n][n - 1];
int last = 0;
int rep = 1;
for (int i = 0; i < n; i++)
{
for (int j = 0; j < n - 1; j++)
{
cin >> input[i][j];
}
}
for (int i = 1; i < n; i++)
{
if (input[0][n - 2] != input[i][n - 2])
{
if (input[0][n - 2] == (input[i - 1][n - 2] || input[i + 1][n - 2]) && i != 0 && i != n - 1)
{
last = i;
break;
}
else{
last=0;
}
}
}
while (true)
{
if (input[rep - 1][n - 2] == (input[rep][n - 2] && input[rep + 1][n - 2]))
{
rep++;
break;
}
}
for (int i = 0; i < n - 1; i++)
{
cout << input[last][i] << " ";
}
cout << input[rep][n - 2] << endl;
}
}