#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
map<P,int> mp;
map<P,bool> vis;
set<P> s;
int dx[8]={1,1,0,-1,-1,-1,0,1};
int dy[8]={0,1,1,1,0,-1,-1,-1};
int main() {
int n,t;
scanf("%d %d",&n,&t);
for(int i=0;i<n;i++) {
int x,y;
scanf("%d %d",&x,&y);
mp[P(x,y)]=i;
}
P st=(*mp.begin()).first;
vis[st]=true;
vector<int> ret;
s.insert(st);
while (!s.empty()) {
P now=*s.begin();
s.erase(now);
ret.push_back(mp[now]);
int x=now.first;
int y=now.second;
for(int i=0;i<8;i++) {
if (mp.find(P(x+dx[i],y+dy[i]))!=mp.end()&&!vis[P(x+dx[i],y+dy[i])]) {
vis[P(x+dx[i],y+dy[i])]=true;
s.insert(P(x+dx[i],y+dy[i]));
}
}
}
if (ret.size()!=n) {
printf("NO");
}
else {
printf("YES\n");
for(int i=0;i<n;i++) {
printf("%d\n",ret[i]+1);
}
}
}
Compilation message
skyscrapers.cpp: In function 'int main()':
skyscrapers.cpp:36:19: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
36 | if (ret.size()!=n) {
| ~~~~~~~~~~^~~
skyscrapers.cpp:13:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
13 | scanf("%d %d",&n,&t);
| ~~~~~^~~~~~~~~~~~~~~
skyscrapers.cpp:16:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
16 | scanf("%d %d",&x,&y);
| ~~~~~^~~~~~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
204 KB |
ans=YES N=1 |
2 |
Correct |
0 ms |
204 KB |
ans=YES N=4 |
3 |
Correct |
0 ms |
204 KB |
ans=NO N=4 |
4 |
Correct |
1 ms |
204 KB |
ans=YES N=5 |
5 |
Correct |
0 ms |
216 KB |
ans=YES N=9 |
6 |
Correct |
1 ms |
204 KB |
ans=YES N=5 |
7 |
Correct |
0 ms |
204 KB |
ans=NO N=9 |
8 |
Correct |
1 ms |
204 KB |
ans=NO N=10 |
9 |
Correct |
1 ms |
204 KB |
ans=YES N=10 |
10 |
Correct |
1 ms |
204 KB |
ans=YES N=10 |
11 |
Correct |
0 ms |
204 KB |
ans=YES N=10 |
12 |
Correct |
1 ms |
204 KB |
ans=YES N=9 |
13 |
Correct |
1 ms |
292 KB |
ans=YES N=9 |
14 |
Correct |
1 ms |
204 KB |
ans=YES N=8 |
15 |
Correct |
0 ms |
204 KB |
ans=YES N=8 |
16 |
Correct |
1 ms |
204 KB |
ans=NO N=2 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
204 KB |
ans=YES N=1 |
2 |
Correct |
0 ms |
204 KB |
ans=YES N=4 |
3 |
Correct |
0 ms |
204 KB |
ans=NO N=4 |
4 |
Correct |
1 ms |
204 KB |
ans=YES N=5 |
5 |
Correct |
0 ms |
216 KB |
ans=YES N=9 |
6 |
Correct |
1 ms |
204 KB |
ans=YES N=5 |
7 |
Correct |
0 ms |
204 KB |
ans=NO N=9 |
8 |
Correct |
1 ms |
204 KB |
ans=NO N=10 |
9 |
Correct |
1 ms |
204 KB |
ans=YES N=10 |
10 |
Correct |
1 ms |
204 KB |
ans=YES N=10 |
11 |
Correct |
0 ms |
204 KB |
ans=YES N=10 |
12 |
Correct |
1 ms |
204 KB |
ans=YES N=9 |
13 |
Correct |
1 ms |
292 KB |
ans=YES N=9 |
14 |
Correct |
1 ms |
204 KB |
ans=YES N=8 |
15 |
Correct |
0 ms |
204 KB |
ans=YES N=8 |
16 |
Correct |
1 ms |
204 KB |
ans=NO N=2 |
17 |
Correct |
1 ms |
204 KB |
ans=YES N=17 |
18 |
Correct |
0 ms |
204 KB |
ans=YES N=25 |
19 |
Correct |
1 ms |
204 KB |
ans=YES N=100 |
20 |
Correct |
1 ms |
204 KB |
ans=YES N=185 |
21 |
Correct |
1 ms |
204 KB |
ans=NO N=174 |
22 |
Correct |
1 ms |
204 KB |
ans=YES N=90 |
23 |
Correct |
1 ms |
204 KB |
ans=YES N=63 |
24 |
Correct |
1 ms |
204 KB |
ans=YES N=87 |
25 |
Correct |
1 ms |
204 KB |
ans=YES N=183 |
26 |
Correct |
1 ms |
204 KB |
ans=YES N=188 |
27 |
Correct |
1 ms |
204 KB |
ans=YES N=183 |
28 |
Correct |
1 ms |
204 KB |
ans=YES N=189 |
29 |
Correct |
1 ms |
204 KB |
ans=YES N=200 |
30 |
Correct |
1 ms |
204 KB |
ans=YES N=190 |
31 |
Correct |
1 ms |
204 KB |
ans=YES N=187 |
32 |
Correct |
1 ms |
204 KB |
ans=YES N=187 |
33 |
Correct |
1 ms |
204 KB |
ans=YES N=182 |
34 |
Correct |
2 ms |
204 KB |
ans=YES N=184 |
35 |
Correct |
1 ms |
204 KB |
ans=YES N=188 |
36 |
Correct |
1 ms |
204 KB |
ans=YES N=181 |
37 |
Correct |
1 ms |
204 KB |
ans=YES N=188 |
38 |
Correct |
1 ms |
204 KB |
ans=YES N=191 |
39 |
Correct |
1 ms |
204 KB |
ans=YES N=196 |
40 |
Correct |
1 ms |
204 KB |
ans=YES N=196 |
41 |
Correct |
1 ms |
204 KB |
ans=YES N=196 |
42 |
Correct |
1 ms |
204 KB |
ans=YES N=196 |
43 |
Correct |
1 ms |
204 KB |
ans=YES N=195 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
204 KB |
ans=YES N=1 |
2 |
Correct |
0 ms |
204 KB |
ans=YES N=4 |
3 |
Correct |
0 ms |
204 KB |
ans=NO N=4 |
4 |
Correct |
1 ms |
204 KB |
ans=YES N=5 |
5 |
Correct |
0 ms |
216 KB |
ans=YES N=9 |
6 |
Correct |
1 ms |
204 KB |
ans=YES N=5 |
7 |
Correct |
0 ms |
204 KB |
ans=NO N=9 |
8 |
Correct |
1 ms |
204 KB |
ans=NO N=10 |
9 |
Correct |
1 ms |
204 KB |
ans=YES N=10 |
10 |
Correct |
1 ms |
204 KB |
ans=YES N=10 |
11 |
Correct |
0 ms |
204 KB |
ans=YES N=10 |
12 |
Correct |
1 ms |
204 KB |
ans=YES N=9 |
13 |
Correct |
1 ms |
292 KB |
ans=YES N=9 |
14 |
Correct |
1 ms |
204 KB |
ans=YES N=8 |
15 |
Correct |
0 ms |
204 KB |
ans=YES N=8 |
16 |
Correct |
1 ms |
204 KB |
ans=NO N=2 |
17 |
Correct |
1 ms |
204 KB |
ans=YES N=17 |
18 |
Correct |
0 ms |
204 KB |
ans=YES N=25 |
19 |
Correct |
1 ms |
204 KB |
ans=YES N=100 |
20 |
Correct |
1 ms |
204 KB |
ans=YES N=185 |
21 |
Correct |
1 ms |
204 KB |
ans=NO N=174 |
22 |
Correct |
1 ms |
204 KB |
ans=YES N=90 |
23 |
Correct |
1 ms |
204 KB |
ans=YES N=63 |
24 |
Correct |
1 ms |
204 KB |
ans=YES N=87 |
25 |
Correct |
1 ms |
204 KB |
ans=YES N=183 |
26 |
Correct |
1 ms |
204 KB |
ans=YES N=188 |
27 |
Correct |
1 ms |
204 KB |
ans=YES N=183 |
28 |
Correct |
1 ms |
204 KB |
ans=YES N=189 |
29 |
Correct |
1 ms |
204 KB |
ans=YES N=200 |
30 |
Correct |
1 ms |
204 KB |
ans=YES N=190 |
31 |
Correct |
1 ms |
204 KB |
ans=YES N=187 |
32 |
Correct |
1 ms |
204 KB |
ans=YES N=187 |
33 |
Correct |
1 ms |
204 KB |
ans=YES N=182 |
34 |
Correct |
2 ms |
204 KB |
ans=YES N=184 |
35 |
Correct |
1 ms |
204 KB |
ans=YES N=188 |
36 |
Correct |
1 ms |
204 KB |
ans=YES N=181 |
37 |
Correct |
1 ms |
204 KB |
ans=YES N=188 |
38 |
Correct |
1 ms |
204 KB |
ans=YES N=191 |
39 |
Correct |
1 ms |
204 KB |
ans=YES N=196 |
40 |
Correct |
1 ms |
204 KB |
ans=YES N=196 |
41 |
Correct |
1 ms |
204 KB |
ans=YES N=196 |
42 |
Correct |
1 ms |
204 KB |
ans=YES N=196 |
43 |
Correct |
1 ms |
204 KB |
ans=YES N=195 |
44 |
Correct |
1 ms |
332 KB |
ans=NO N=1934 |
45 |
Correct |
2 ms |
332 KB |
ans=NO N=1965 |
46 |
Correct |
4 ms |
460 KB |
ans=YES N=1824 |
47 |
Correct |
4 ms |
460 KB |
ans=YES N=1981 |
48 |
Correct |
4 ms |
460 KB |
ans=YES N=1814 |
49 |
Correct |
4 ms |
460 KB |
ans=YES N=1854 |
50 |
Correct |
4 ms |
460 KB |
ans=YES N=1831 |
51 |
Correct |
5 ms |
588 KB |
ans=YES N=2000 |
52 |
Correct |
4 ms |
460 KB |
ans=YES N=1847 |
53 |
Correct |
4 ms |
460 KB |
ans=YES N=1819 |
54 |
Correct |
5 ms |
588 KB |
ans=YES N=1986 |
55 |
Correct |
4 ms |
588 KB |
ans=YES N=2000 |
56 |
Correct |
4 ms |
480 KB |
ans=YES N=1834 |
57 |
Correct |
4 ms |
460 KB |
ans=YES N=1860 |
58 |
Correct |
4 ms |
588 KB |
ans=YES N=1898 |
59 |
Correct |
4 ms |
460 KB |
ans=YES N=1832 |
60 |
Correct |
4 ms |
588 KB |
ans=YES N=1929 |
61 |
Correct |
4 ms |
588 KB |
ans=YES N=1919 |
62 |
Correct |
4 ms |
588 KB |
ans=YES N=1882 |
63 |
Correct |
4 ms |
496 KB |
ans=YES N=1922 |
64 |
Correct |
4 ms |
588 KB |
ans=YES N=1989 |
65 |
Correct |
3 ms |
588 KB |
ans=YES N=1978 |
66 |
Correct |
4 ms |
460 KB |
ans=YES N=1867 |
67 |
Correct |
4 ms |
588 KB |
ans=YES N=1942 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
432 KB |
ans=NO N=1934 |
2 |
Correct |
1 ms |
332 KB |
ans=NO N=1965 |
3 |
Incorrect |
4 ms |
460 KB |
Contestant's solution is not lexicographically largest at index 1824 (1813 vs 1702) |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
204 KB |
ans=YES N=1 |
2 |
Correct |
0 ms |
204 KB |
ans=YES N=4 |
3 |
Correct |
0 ms |
204 KB |
ans=NO N=4 |
4 |
Correct |
1 ms |
204 KB |
ans=YES N=5 |
5 |
Correct |
0 ms |
216 KB |
ans=YES N=9 |
6 |
Correct |
1 ms |
204 KB |
ans=YES N=5 |
7 |
Correct |
0 ms |
204 KB |
ans=NO N=9 |
8 |
Correct |
1 ms |
204 KB |
ans=NO N=10 |
9 |
Correct |
1 ms |
204 KB |
ans=YES N=10 |
10 |
Correct |
1 ms |
204 KB |
ans=YES N=10 |
11 |
Correct |
0 ms |
204 KB |
ans=YES N=10 |
12 |
Correct |
1 ms |
204 KB |
ans=YES N=9 |
13 |
Correct |
1 ms |
292 KB |
ans=YES N=9 |
14 |
Correct |
1 ms |
204 KB |
ans=YES N=8 |
15 |
Correct |
0 ms |
204 KB |
ans=YES N=8 |
16 |
Correct |
1 ms |
204 KB |
ans=NO N=2 |
17 |
Correct |
1 ms |
204 KB |
ans=YES N=17 |
18 |
Correct |
0 ms |
204 KB |
ans=YES N=25 |
19 |
Correct |
1 ms |
204 KB |
ans=YES N=100 |
20 |
Correct |
1 ms |
204 KB |
ans=YES N=185 |
21 |
Correct |
1 ms |
204 KB |
ans=NO N=174 |
22 |
Correct |
1 ms |
204 KB |
ans=YES N=90 |
23 |
Correct |
1 ms |
204 KB |
ans=YES N=63 |
24 |
Correct |
1 ms |
204 KB |
ans=YES N=87 |
25 |
Correct |
1 ms |
204 KB |
ans=YES N=183 |
26 |
Correct |
1 ms |
204 KB |
ans=YES N=188 |
27 |
Correct |
1 ms |
204 KB |
ans=YES N=183 |
28 |
Correct |
1 ms |
204 KB |
ans=YES N=189 |
29 |
Correct |
1 ms |
204 KB |
ans=YES N=200 |
30 |
Correct |
1 ms |
204 KB |
ans=YES N=190 |
31 |
Correct |
1 ms |
204 KB |
ans=YES N=187 |
32 |
Correct |
1 ms |
204 KB |
ans=YES N=187 |
33 |
Correct |
1 ms |
204 KB |
ans=YES N=182 |
34 |
Correct |
2 ms |
204 KB |
ans=YES N=184 |
35 |
Correct |
1 ms |
204 KB |
ans=YES N=188 |
36 |
Correct |
1 ms |
204 KB |
ans=YES N=181 |
37 |
Correct |
1 ms |
204 KB |
ans=YES N=188 |
38 |
Correct |
1 ms |
204 KB |
ans=YES N=191 |
39 |
Correct |
1 ms |
204 KB |
ans=YES N=196 |
40 |
Correct |
1 ms |
204 KB |
ans=YES N=196 |
41 |
Correct |
1 ms |
204 KB |
ans=YES N=196 |
42 |
Correct |
1 ms |
204 KB |
ans=YES N=196 |
43 |
Correct |
1 ms |
204 KB |
ans=YES N=195 |
44 |
Correct |
1 ms |
332 KB |
ans=NO N=1934 |
45 |
Correct |
2 ms |
332 KB |
ans=NO N=1965 |
46 |
Correct |
4 ms |
460 KB |
ans=YES N=1824 |
47 |
Correct |
4 ms |
460 KB |
ans=YES N=1981 |
48 |
Correct |
4 ms |
460 KB |
ans=YES N=1814 |
49 |
Correct |
4 ms |
460 KB |
ans=YES N=1854 |
50 |
Correct |
4 ms |
460 KB |
ans=YES N=1831 |
51 |
Correct |
5 ms |
588 KB |
ans=YES N=2000 |
52 |
Correct |
4 ms |
460 KB |
ans=YES N=1847 |
53 |
Correct |
4 ms |
460 KB |
ans=YES N=1819 |
54 |
Correct |
5 ms |
588 KB |
ans=YES N=1986 |
55 |
Correct |
4 ms |
588 KB |
ans=YES N=2000 |
56 |
Correct |
4 ms |
480 KB |
ans=YES N=1834 |
57 |
Correct |
4 ms |
460 KB |
ans=YES N=1860 |
58 |
Correct |
4 ms |
588 KB |
ans=YES N=1898 |
59 |
Correct |
4 ms |
460 KB |
ans=YES N=1832 |
60 |
Correct |
4 ms |
588 KB |
ans=YES N=1929 |
61 |
Correct |
4 ms |
588 KB |
ans=YES N=1919 |
62 |
Correct |
4 ms |
588 KB |
ans=YES N=1882 |
63 |
Correct |
4 ms |
496 KB |
ans=YES N=1922 |
64 |
Correct |
4 ms |
588 KB |
ans=YES N=1989 |
65 |
Correct |
3 ms |
588 KB |
ans=YES N=1978 |
66 |
Correct |
4 ms |
460 KB |
ans=YES N=1867 |
67 |
Correct |
4 ms |
588 KB |
ans=YES N=1942 |
68 |
Correct |
164 ms |
9484 KB |
ans=NO N=66151 |
69 |
Correct |
39 ms |
4780 KB |
ans=NO N=64333 |
70 |
Correct |
194 ms |
10280 KB |
ans=YES N=69316 |
71 |
Correct |
185 ms |
9788 KB |
ans=YES N=66695 |
72 |
Correct |
196 ms |
10076 KB |
ans=YES N=68436 |
73 |
Correct |
195 ms |
10300 KB |
ans=YES N=70000 |
74 |
Correct |
206 ms |
10172 KB |
ans=YES N=68501 |
75 |
Correct |
189 ms |
10300 KB |
ans=YES N=70000 |
76 |
Correct |
162 ms |
9604 KB |
ans=YES N=65009 |
77 |
Correct |
159 ms |
9968 KB |
ans=YES N=67007 |
78 |
Correct |
151 ms |
9836 KB |
ans=YES N=66357 |
79 |
Correct |
147 ms |
9644 KB |
ans=YES N=65430 |
80 |
Correct |
147 ms |
9588 KB |
ans=YES N=65790 |
81 |
Correct |
147 ms |
9664 KB |
ans=YES N=66020 |
82 |
Correct |
154 ms |
9664 KB |
ans=YES N=65809 |
83 |
Correct |
164 ms |
9788 KB |
ans=YES N=65651 |
84 |
Correct |
155 ms |
10036 KB |
ans=YES N=68040 |
85 |
Correct |
147 ms |
9788 KB |
ans=YES N=66570 |
86 |
Correct |
170 ms |
9520 KB |
ans=YES N=65421 |
87 |
Correct |
171 ms |
10044 KB |
ans=YES N=68351 |
88 |
Correct |
202 ms |
9788 KB |
ans=YES N=67027 |
89 |
Correct |
114 ms |
10260 KB |
ans=YES N=68879 |
90 |
Correct |
197 ms |
10072 KB |
ans=YES N=67256 |
91 |
Correct |
466 ms |
21660 KB |
ans=YES N=148315 |
92 |
Correct |
117 ms |
10356 KB |
ans=NO N=142745 |
93 |
Correct |
132 ms |
12568 KB |
ans=NO N=148443 |
94 |
Correct |
486 ms |
23412 KB |
ans=YES N=148328 |
95 |
Correct |
496 ms |
23344 KB |
ans=YES N=147855 |
96 |
Correct |
481 ms |
23732 KB |
ans=YES N=150000 |
97 |
Correct |
468 ms |
22880 KB |
ans=YES N=144725 |
98 |
Correct |
489 ms |
23568 KB |
ans=YES N=149445 |
99 |
Correct |
487 ms |
23092 KB |
ans=YES N=144455 |
100 |
Correct |
481 ms |
22612 KB |
ans=YES N=143487 |
101 |
Correct |
492 ms |
23464 KB |
ans=YES N=149688 |
102 |
Correct |
381 ms |
22452 KB |
ans=YES N=141481 |
103 |
Correct |
393 ms |
23284 KB |
ans=YES N=147430 |
104 |
Correct |
404 ms |
22584 KB |
ans=YES N=142247 |
105 |
Correct |
471 ms |
23868 KB |
ans=YES N=149941 |
106 |
Correct |
371 ms |
22564 KB |
ans=YES N=141635 |
107 |
Correct |
368 ms |
22448 KB |
ans=YES N=142896 |
108 |
Correct |
401 ms |
22056 KB |
ans=YES N=142069 |
109 |
Correct |
466 ms |
21812 KB |
ans=YES N=142378 |
110 |
Correct |
409 ms |
23600 KB |
ans=YES N=150000 |
111 |
Correct |
341 ms |
22100 KB |
ans=YES N=141452 |
112 |
Correct |
313 ms |
21216 KB |
ans=YES N=134453 |
113 |
Correct |
324 ms |
22576 KB |
ans=YES N=144172 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
171 ms |
9512 KB |
ans=NO N=66151 |
2 |
Correct |
45 ms |
4812 KB |
ans=NO N=64333 |
3 |
Incorrect |
206 ms |
10128 KB |
Contestant's solution is not lexicographically largest at index 69316 (69235 vs 7320) |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
432 KB |
ans=NO N=1934 |
2 |
Correct |
1 ms |
332 KB |
ans=NO N=1965 |
3 |
Incorrect |
4 ms |
460 KB |
Contestant's solution is not lexicographically largest at index 1824 (1813 vs 1702) |
4 |
Halted |
0 ms |
0 KB |
- |