-
Notifications
You must be signed in to change notification settings - Fork 1
/
TRNGLFLD.cpp
executable file
·92 lines (68 loc) · 1.71 KB
/
TRNGLFLD.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
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
89
90
91
92
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <algorithm>
#define FOR(i,a,b) for(long long i = a ; i < b ; ++i )
#define PB push_back
using namespace std;
const int size = 45009;
struct input{
int x;
int y;
int numer;
};
bool malejacoYcomp( input a , input b ){
return a.y > b.y;
}
bool malejacoXcomp( input a , input b ){
return a.x > b.x;
}
bool forbidden[ size ];
int main(){
long long t;
long long n;
input in;
vector<int> help(4);
vector <input> malejacoX(size);
vector <input> malejacoY(size);
scanf("%lld",&t);
FOR( i , 0 , t){
scanf("%lld",&n);
FOR( j, 0 , n ){
forbidden[ j+1 ] = false;
scanf("%d %d",&in.x,&in.y);
in.numer = j+1;
malejacoX[ j ] = malejacoY[ j ] = in ;
}
sort( malejacoY.begin(),malejacoY.begin() + n ,malejacoYcomp );
sort( malejacoX.begin(),malejacoX.begin() + n ,malejacoXcomp );
vector< input >::iterator mxk = malejacoX.begin() + n-1;
vector< input >::iterator mxp = malejacoX.begin();
vector< input >::iterator myp = malejacoY.begin();
vector< input >::iterator myk = malejacoY.begin() + n-1;
FOR( j , 0 , n/3 ){
while ( forbidden[(help[ 0 ] = (*mxp).numer)] )
mxp++ ;
while ( forbidden[(help[ 1 ] = (*myp).numer)] )
myp++;
while ( forbidden[(help[ 2 ] = (*mxk).numer)] )
mxk--;
while ( forbidden[(help[ 3 ] = (*myk).numer)] ) myk--;
forbidden[ help[ 0 ] ] = true;
forbidden[ help[ 1 ] ] = true;
forbidden[ help[ 2 ] ] = true;
forbidden[ help[ 3 ] ] = true;
sort( help.begin(), help.end() );
printf( "%d ",help[0]);
FOR( k , 1 , 4){
if( help[ k ] != help[ k -1 ]){
printf( "%d ",help[k]);
}
}
printf("\n");
}
printf("\n");
}
return 0 ;
}