-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path310b.cpp
More file actions
74 lines (71 loc) · 1.45 KB
/
310b.cpp
File metadata and controls
74 lines (71 loc) · 1.45 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
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pii pair < int , int >
#define pb push_back
#define mp make_pair
#define mod 1000000009
const int N = 888;
int arr[N][N];
int ans[N];
bool vis[N];
void dfs(int x, int par, int n){
if (ans[x] != 0) return ;
int mx = -1, idx = 0;
for (int i = 1; i<=n; i++){
if (ans[i] == 0 && arr[x][i] > mx){
mx = arr[x][i];
idx = i;
}
}
if (idx == par && idx != 0){
ans[idx] = x;
ans[x] = idx;
}
else dfs(idx, x, n);
}
int main(){
int n;
cin >> n;
n = n * 2;
for (int i = 2; i<=n ;i++){
for (int j = 1; j<i; j++){
cin >> arr[i][j];
arr[j][i] = arr[i][j];
}
}
for (int i = 1; i<=n; i++) dfs(i, 0, n);
// for (int i = 1; i<=n; i++){
// int tmp = -1;
// // if (vis[i]) continue;
// // vis[i] = true;
// if (ans[i]) continue;
// for(int j = 1; j<=n; j++){
// if (vis[j] || i == j) continue;
// int temp = arr[i][j];
// int flag = 0;
// for (int k = 1; k<=n; k++){
// // if (k == i) continue;
// if (ans[k] == 0 && temp < arr[j][k]){
// flag = 1;
// break;
// }
// }
// if (flag == 0 && tmp < arr[i][j]){
// vis[ans[i]] = false;
// vis[j] = true;
// ans[i] = j;
// ans[j] = i;
// tmp = arr[i][j];
// }
// }
// if (ans[i] != 0) vis[i] = 1;
// // for (int k = 1; k <= n; k++)
// // cout << vis[k] << " ";
// // cout << endl;
// }
for (int i = 1; i<=n; i++)
cout << ans[i] << " ";
cout << endl;
return 0;
}