-
Notifications
You must be signed in to change notification settings - Fork 0
/
1199.cpp
49 lines (42 loc) · 799 Bytes
/
1199.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
48
49
#include<iostream>
#define N 1005
using namespace std;
int map[N][N], n, lc[N];
void dfs(int index)
{
int i;
for(i=1; i<=n; i++){
while(map[index][i]){
map[index][i]--;
map[i][index]--;
dfs(i);
}
}
printf("%d ", index);
}
int main()
{
ios::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
freopen("input.txt","r",stdin);
freopen("output.txt","w",stdout);
int i, j;
cin >> n;
for(i=1; i<=n; i++){
for(j=1; j<=n; j++){
cin >> map[i][j];
lc[i]+=map[i][j];
lc[j]+=map[i][j];
}
}
for(i=1; i<=n; i++){
lc[i]/=2;
if(lc[i]%2){
printf("-1");
return 0;
}
}
dfs(1);
return 0;
}