# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
38425 |
2018-01-04T05:45:59 Z |
kajebiii |
None (KOI16_laser) |
C++14 |
|
409 ms |
37072 KB |
#include <bits/stdc++.h>
using namespace std;
#define SZ(v) ((int)(v).size())
#define ALL(v) (v).begin(),(v).end()
#define one first
#define two second
typedef long long ll;
typedef pair<int, int> pi;
const int INF = 0x3f2f1f0f;
const ll LINF = 1ll * INF * INF;
int sign(ll x) {return (x>0) - (x<0);}
struct PT{
int x, y, c, ix;
PT() {}
PT(int xx, int yy) : x(xx), y(yy), c(-10), ix(-10) {}
PT(int xx, int yy, int cc, int ii) : x(xx), y(yy), c(cc), ix(ii) {}
PT operator-(const PT &o) const{return PT(x-o.x, y-o.y);}
ll cross(const PT &o) const{return 1ll*x*o.y - 1ll*y*o.x;}
ll cross(const PT &a, const PT &b) const{return (a-*this).cross(b-*this);}
int ccw(const PT &o) const{return sign(cross(o));}
int ccw(const PT &a, const PT &b) const{return sign(cross(a, b));}
};
const int MAX_N = 1e3 + 10;
int N;
vector<PT> Ps;
int Ans[MAX_N][2];
void getAns(vector<PT> &ps) {
if(SZ(ps) == 0) return;
int n = SZ(ps);
for(int i=1; i<n; i++) if(ps[0].y > ps[i].y || ps[0].y == ps[i].y && ps[0].x > ps[i].x) swap(ps[0], ps[i]);
sort(ps.begin()+1, ps.end(), [&](PT &a, PT &b) {return ps[0].ccw(a, b) > 0;});
vector<PT> cv; vector<int> index;
for(int i=0; i<n; i++) {
while(SZ(cv) >= 2 && cv[SZ(cv)-2].ccw(cv.back(), ps[i]) <= 0) cv.pop_back(), index.pop_back();
cv.push_back(ps[i]); index.push_back(i);
}
int cix = -1;
for(int i=0; i<SZ(cv); i++) if(cv[i].c == 2) {cix = index[i]; break;}
{
vector<PT> t; vector<int> tt;
swap(t, cv); swap(tt, index);
}
if(cix != -1) {
swap(ps[0], ps[cix]);
sort(ps.begin()+1, ps.end(), [&](PT &a, PT &b) {return ps[0].ccw(a, b) > 0;});
int ix = ps[0].ix;
int now = 2, limit = 1, cnt = 0;
vector<PT> nps[3];
for(int i=1; i<n; i++) {
now += ps[i].c;
if(ps[i].c == -1 && now == limit && limit != -1) {
Ans[ix][cnt] = ps[i].ix;
limit--; cnt++;
}else nps[cnt].push_back(ps[i]);
}
for(int i=0; i<3; i++) getAns(nps[i]);
}else{
int now = 0, cnt = 0;
vector<PT> nps[2];
for(int i=0; i<n; i++) {
now += ps[i%n].c;
nps[cnt].push_back(ps[i%n]);
if(cnt == 0 && now == 0) cnt++;
}
if(SZ(nps[1]) == 0) {
nps[0].clear(); nps[1].clear();
now = cnt = 0;
for(int i=n; i>=1; i--) {
now += ps[i%n].c;
nps[cnt].push_back(ps[i%n]);
if(cnt == 0 && now == 0) cnt++;
}
}
for(int i=0; i<2; i++) getAns(nps[i]);
}
}
int main() {
cin >> N;
for(int i=0; i<3*N; i++) {
int x, y; scanf("%d%d", &x, &y);
Ps.emplace_back(x, y, i<N?2:-1, i<N?i:i-N);
}
getAns(Ps);
for(int i=0; i<N; i++) printf("%d %d\n", Ans[i][0]+1, Ans[i][1]+1);
return 0;
}
Compilation message
laser.cpp: In function 'void getAns(std::vector<PT>&)':
laser.cpp:36:68: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
for(int i=1; i<n; i++) if(ps[0].y > ps[i].y || ps[0].y == ps[i].y && ps[0].x > ps[i].x) swap(ps[0], ps[i]);
^
laser.cpp: In function 'int main()':
laser.cpp:87:34: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
int x, y; scanf("%d%d", &x, &y);
^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
2032 KB |
Output is correct |
2 |
Correct |
0 ms |
2032 KB |
Output is correct |
3 |
Correct |
0 ms |
2032 KB |
Output is correct |
4 |
Correct |
0 ms |
2032 KB |
Output is correct |
5 |
Correct |
0 ms |
2032 KB |
Output is correct |
6 |
Correct |
0 ms |
2032 KB |
Output is correct |
7 |
Correct |
0 ms |
2032 KB |
Output is correct |
8 |
Correct |
0 ms |
2032 KB |
Output is correct |
9 |
Correct |
0 ms |
2032 KB |
Output is correct |
10 |
Correct |
0 ms |
2032 KB |
Output is correct |
11 |
Correct |
0 ms |
2032 KB |
Output is correct |
12 |
Correct |
0 ms |
2032 KB |
Output is correct |
13 |
Correct |
0 ms |
2032 KB |
Output is correct |
14 |
Correct |
0 ms |
2032 KB |
Output is correct |
15 |
Correct |
0 ms |
2032 KB |
Output is correct |
16 |
Correct |
0 ms |
2032 KB |
Output is correct |
17 |
Correct |
0 ms |
2032 KB |
Output is correct |
18 |
Correct |
0 ms |
2032 KB |
Output is correct |
19 |
Correct |
0 ms |
2032 KB |
Output is correct |
20 |
Correct |
0 ms |
2032 KB |
Output is correct |
21 |
Correct |
0 ms |
2032 KB |
Output is correct |
22 |
Correct |
0 ms |
2032 KB |
Output is correct |
23 |
Correct |
0 ms |
2032 KB |
Output is correct |
24 |
Correct |
0 ms |
2032 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
2164 KB |
Output is correct |
2 |
Correct |
0 ms |
2164 KB |
Output is correct |
3 |
Correct |
0 ms |
2164 KB |
Output is correct |
4 |
Correct |
0 ms |
2032 KB |
Output is correct |
5 |
Correct |
0 ms |
2164 KB |
Output is correct |
6 |
Correct |
0 ms |
2164 KB |
Output is correct |
7 |
Correct |
0 ms |
2032 KB |
Output is correct |
8 |
Correct |
0 ms |
2164 KB |
Output is correct |
9 |
Correct |
0 ms |
2032 KB |
Output is correct |
10 |
Correct |
0 ms |
2164 KB |
Output is correct |
11 |
Correct |
3 ms |
2412 KB |
Output is correct |
12 |
Correct |
0 ms |
2260 KB |
Output is correct |
13 |
Correct |
3 ms |
2412 KB |
Output is correct |
14 |
Correct |
0 ms |
2412 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
2032 KB |
Output is correct |
2 |
Correct |
0 ms |
2032 KB |
Output is correct |
3 |
Correct |
0 ms |
2032 KB |
Output is correct |
4 |
Correct |
0 ms |
2032 KB |
Output is correct |
5 |
Correct |
0 ms |
2032 KB |
Output is correct |
6 |
Correct |
0 ms |
2032 KB |
Output is correct |
7 |
Correct |
0 ms |
2032 KB |
Output is correct |
8 |
Correct |
0 ms |
2032 KB |
Output is correct |
9 |
Correct |
0 ms |
2032 KB |
Output is correct |
10 |
Correct |
0 ms |
2032 KB |
Output is correct |
11 |
Correct |
0 ms |
2032 KB |
Output is correct |
12 |
Correct |
0 ms |
2032 KB |
Output is correct |
13 |
Correct |
0 ms |
2032 KB |
Output is correct |
14 |
Correct |
0 ms |
2032 KB |
Output is correct |
15 |
Correct |
0 ms |
2032 KB |
Output is correct |
16 |
Correct |
0 ms |
2032 KB |
Output is correct |
17 |
Correct |
0 ms |
2032 KB |
Output is correct |
18 |
Correct |
0 ms |
2032 KB |
Output is correct |
19 |
Correct |
0 ms |
2032 KB |
Output is correct |
20 |
Correct |
0 ms |
2032 KB |
Output is correct |
21 |
Correct |
0 ms |
2032 KB |
Output is correct |
22 |
Correct |
0 ms |
2032 KB |
Output is correct |
23 |
Correct |
0 ms |
2032 KB |
Output is correct |
24 |
Correct |
0 ms |
2032 KB |
Output is correct |
25 |
Correct |
0 ms |
2164 KB |
Output is correct |
26 |
Correct |
0 ms |
2164 KB |
Output is correct |
27 |
Correct |
0 ms |
2164 KB |
Output is correct |
28 |
Correct |
0 ms |
2032 KB |
Output is correct |
29 |
Correct |
0 ms |
2164 KB |
Output is correct |
30 |
Correct |
0 ms |
2164 KB |
Output is correct |
31 |
Correct |
0 ms |
2032 KB |
Output is correct |
32 |
Correct |
0 ms |
2164 KB |
Output is correct |
33 |
Correct |
0 ms |
2032 KB |
Output is correct |
34 |
Correct |
0 ms |
2164 KB |
Output is correct |
35 |
Correct |
3 ms |
2412 KB |
Output is correct |
36 |
Correct |
0 ms |
2260 KB |
Output is correct |
37 |
Correct |
3 ms |
2412 KB |
Output is correct |
38 |
Correct |
0 ms |
2412 KB |
Output is correct |
39 |
Correct |
0 ms |
2032 KB |
Output is correct |
40 |
Correct |
0 ms |
2032 KB |
Output is correct |
41 |
Correct |
0 ms |
2164 KB |
Output is correct |
42 |
Correct |
0 ms |
2164 KB |
Output is correct |
43 |
Correct |
0 ms |
2164 KB |
Output is correct |
44 |
Correct |
0 ms |
2032 KB |
Output is correct |
45 |
Correct |
0 ms |
2032 KB |
Output is correct |
46 |
Correct |
0 ms |
2164 KB |
Output is correct |
47 |
Correct |
0 ms |
2168 KB |
Output is correct |
48 |
Correct |
0 ms |
2164 KB |
Output is correct |
49 |
Correct |
0 ms |
2412 KB |
Output is correct |
50 |
Correct |
3 ms |
2412 KB |
Output is correct |
51 |
Correct |
0 ms |
2412 KB |
Output is correct |
52 |
Correct |
0 ms |
2412 KB |
Output is correct |
53 |
Correct |
0 ms |
2412 KB |
Output is correct |
54 |
Correct |
0 ms |
2412 KB |
Output is correct |
55 |
Correct |
3 ms |
2412 KB |
Output is correct |
56 |
Correct |
0 ms |
2412 KB |
Output is correct |
57 |
Correct |
0 ms |
2032 KB |
Output is correct |
58 |
Correct |
3 ms |
2428 KB |
Output is correct |
59 |
Correct |
0 ms |
2164 KB |
Output is correct |
60 |
Correct |
0 ms |
2032 KB |
Output is correct |
61 |
Correct |
0 ms |
2164 KB |
Output is correct |
62 |
Correct |
0 ms |
2164 KB |
Output is correct |
63 |
Correct |
0 ms |
2164 KB |
Output is correct |
64 |
Correct |
0 ms |
2168 KB |
Output is correct |
65 |
Correct |
0 ms |
2164 KB |
Output is correct |
66 |
Correct |
0 ms |
2032 KB |
Output is correct |
67 |
Correct |
0 ms |
2164 KB |
Output is correct |
68 |
Correct |
0 ms |
2032 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
2032 KB |
Output is correct |
2 |
Correct |
0 ms |
2032 KB |
Output is correct |
3 |
Correct |
0 ms |
2032 KB |
Output is correct |
4 |
Correct |
0 ms |
2032 KB |
Output is correct |
5 |
Correct |
0 ms |
2032 KB |
Output is correct |
6 |
Correct |
0 ms |
2032 KB |
Output is correct |
7 |
Correct |
0 ms |
2032 KB |
Output is correct |
8 |
Correct |
0 ms |
2032 KB |
Output is correct |
9 |
Correct |
0 ms |
2032 KB |
Output is correct |
10 |
Correct |
0 ms |
2032 KB |
Output is correct |
11 |
Correct |
0 ms |
2032 KB |
Output is correct |
12 |
Correct |
0 ms |
2032 KB |
Output is correct |
13 |
Correct |
0 ms |
2032 KB |
Output is correct |
14 |
Correct |
0 ms |
2032 KB |
Output is correct |
15 |
Correct |
0 ms |
2032 KB |
Output is correct |
16 |
Correct |
0 ms |
2032 KB |
Output is correct |
17 |
Correct |
0 ms |
2032 KB |
Output is correct |
18 |
Correct |
0 ms |
2032 KB |
Output is correct |
19 |
Correct |
0 ms |
2032 KB |
Output is correct |
20 |
Correct |
0 ms |
2032 KB |
Output is correct |
21 |
Correct |
0 ms |
2032 KB |
Output is correct |
22 |
Correct |
0 ms |
2032 KB |
Output is correct |
23 |
Correct |
0 ms |
2032 KB |
Output is correct |
24 |
Correct |
0 ms |
2032 KB |
Output is correct |
25 |
Correct |
0 ms |
2164 KB |
Output is correct |
26 |
Correct |
0 ms |
2164 KB |
Output is correct |
27 |
Correct |
0 ms |
2164 KB |
Output is correct |
28 |
Correct |
0 ms |
2032 KB |
Output is correct |
29 |
Correct |
0 ms |
2164 KB |
Output is correct |
30 |
Correct |
0 ms |
2164 KB |
Output is correct |
31 |
Correct |
0 ms |
2032 KB |
Output is correct |
32 |
Correct |
0 ms |
2164 KB |
Output is correct |
33 |
Correct |
0 ms |
2032 KB |
Output is correct |
34 |
Correct |
0 ms |
2164 KB |
Output is correct |
35 |
Correct |
3 ms |
2412 KB |
Output is correct |
36 |
Correct |
0 ms |
2260 KB |
Output is correct |
37 |
Correct |
3 ms |
2412 KB |
Output is correct |
38 |
Correct |
0 ms |
2412 KB |
Output is correct |
39 |
Correct |
0 ms |
2032 KB |
Output is correct |
40 |
Correct |
0 ms |
2032 KB |
Output is correct |
41 |
Correct |
0 ms |
2164 KB |
Output is correct |
42 |
Correct |
0 ms |
2164 KB |
Output is correct |
43 |
Correct |
0 ms |
2164 KB |
Output is correct |
44 |
Correct |
0 ms |
2032 KB |
Output is correct |
45 |
Correct |
0 ms |
2032 KB |
Output is correct |
46 |
Correct |
0 ms |
2164 KB |
Output is correct |
47 |
Correct |
0 ms |
2168 KB |
Output is correct |
48 |
Correct |
0 ms |
2164 KB |
Output is correct |
49 |
Correct |
0 ms |
2412 KB |
Output is correct |
50 |
Correct |
3 ms |
2412 KB |
Output is correct |
51 |
Correct |
0 ms |
2412 KB |
Output is correct |
52 |
Correct |
0 ms |
2412 KB |
Output is correct |
53 |
Correct |
0 ms |
2412 KB |
Output is correct |
54 |
Correct |
0 ms |
2412 KB |
Output is correct |
55 |
Correct |
3 ms |
2412 KB |
Output is correct |
56 |
Correct |
0 ms |
2412 KB |
Output is correct |
57 |
Correct |
0 ms |
2032 KB |
Output is correct |
58 |
Correct |
3 ms |
2428 KB |
Output is correct |
59 |
Correct |
0 ms |
2164 KB |
Output is correct |
60 |
Correct |
0 ms |
2032 KB |
Output is correct |
61 |
Correct |
0 ms |
2164 KB |
Output is correct |
62 |
Correct |
0 ms |
2164 KB |
Output is correct |
63 |
Correct |
0 ms |
2164 KB |
Output is correct |
64 |
Correct |
0 ms |
2168 KB |
Output is correct |
65 |
Correct |
0 ms |
2164 KB |
Output is correct |
66 |
Correct |
0 ms |
2032 KB |
Output is correct |
67 |
Correct |
0 ms |
2164 KB |
Output is correct |
68 |
Correct |
0 ms |
2032 KB |
Output is correct |
69 |
Correct |
33 ms |
3964 KB |
Output is correct |
70 |
Correct |
33 ms |
4548 KB |
Output is correct |
71 |
Correct |
29 ms |
3152 KB |
Output is correct |
72 |
Correct |
23 ms |
3308 KB |
Output is correct |
73 |
Correct |
16 ms |
2736 KB |
Output is correct |
74 |
Correct |
49 ms |
6560 KB |
Output is correct |
75 |
Correct |
33 ms |
4088 KB |
Output is correct |
76 |
Correct |
49 ms |
5932 KB |
Output is correct |
77 |
Correct |
26 ms |
4108 KB |
Output is correct |
78 |
Correct |
23 ms |
3280 KB |
Output is correct |
79 |
Correct |
223 ms |
37032 KB |
Output is correct |
80 |
Correct |
273 ms |
37036 KB |
Output is correct |
81 |
Correct |
239 ms |
37032 KB |
Output is correct |
82 |
Correct |
289 ms |
37032 KB |
Output is correct |
83 |
Correct |
169 ms |
37032 KB |
Output is correct |
84 |
Correct |
176 ms |
37036 KB |
Output is correct |
85 |
Correct |
173 ms |
37032 KB |
Output is correct |
86 |
Correct |
176 ms |
37036 KB |
Output is correct |
87 |
Correct |
16 ms |
3700 KB |
Output is correct |
88 |
Correct |
23 ms |
4384 KB |
Output is correct |
89 |
Correct |
409 ms |
37072 KB |
Output is correct |
90 |
Correct |
6 ms |
2800 KB |
Output is correct |
91 |
Correct |
66 ms |
6224 KB |
Output is correct |
92 |
Correct |
46 ms |
4112 KB |
Output is correct |
93 |
Correct |
66 ms |
5088 KB |
Output is correct |
94 |
Correct |
19 ms |
3588 KB |
Output is correct |
95 |
Correct |
26 ms |
3440 KB |
Output is correct |
96 |
Correct |
26 ms |
3636 KB |
Output is correct |
97 |
Correct |
39 ms |
5200 KB |
Output is correct |
98 |
Correct |
33 ms |
4432 KB |
Output is correct |