-
Notifications
You must be signed in to change notification settings - Fork 0
/
59650597.cpp
50 lines (50 loc) · 942 Bytes
/
59650597.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
50
#include <bits/stdc++.h>
using namespace std;
struct querry
{
int row;
int col;
int val;
};
bool cmp(struct querry a,struct querry b);
int main()
{
int n;
cin>>n;
vector<struct querry> data;
for(int i=2;i<=2*n;i++)
{
for(int j=1;j<i;j++)
{
int c;
scanf("%d",&c);
struct querry a;
a.row=i;
a.col=j;
a.val=c;
data.push_back(a);
}
}
sort(data.begin(),data.end(),cmp);
int arr[2*n+1];
fill(arr,arr+2*n+1,0);
int have=0;
for(int i=0;i<data.size();i++)
{
int c=data[i].row;
int d=data[i].col;
if(arr[c]==0 && arr[d]==0)
{
have+=2;
arr[c]=d;
arr[d]=c;
}
}
for(int i=1;i<=2*n;i++)
printf("%d ",arr[i]);
return 0;
}
bool cmp(struct querry a,struct querry b)
{
return a.val>b.val;
}