#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
map<P,int> mp;
map<P,bool> vis;
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;
deque<P> q;
q.push_front(st);
vector<int> ret;
while (!q.empty()) {
P now=q.front();
ret.push_back(mp[now]);
q.pop_front();
int x=now.first;
int y=now.second;
if (mp.find(P(x,y-1))!=mp.end()&&!vis[P(x,y-1)]) {
q.push_front(P(x,y-1));
vis[P(x,y-1)]=true;
}
if (mp.find(P(x,y+1))!=mp.end()&&!vis[P(x,y+1)]) {
q.push_front(P(x,y+1));
vis[P(x,y+1)]=true;
}
for(int d=-1;d<=1;d++) {
if (mp.find(P(x+1,y+d))!=mp.end()&&!vis[P(x+1,y+d)]) {
q.push_back(P(x+1,y+d));
vis[P(x+1,y+d)]=true;
}
if (mp.find(P(x-1,y+d))!=mp.end()&&!vis[P(x-1,y+d)]) {
q.push_back(P(x-1,y+d));
vis[P(x-1,y+d)]=true;
}
}
}
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:46:19: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
46 | if (ret.size()!=n) {
| ~~~~~~~~~~^~~
skyscrapers.cpp:10:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
10 | scanf("%d %d",&n,&t);
| ~~~~~^~~~~~~~~~~~~~~
skyscrapers.cpp:13:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
13 | scanf("%d %d",&x,&y);
| ~~~~~^~~~~~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
ans=YES N=1 |
2 |
Correct |
0 ms |
204 KB |
ans=YES N=4 |
3 |
Correct |
1 ms |
204 KB |
ans=NO N=4 |
4 |
Correct |
0 ms |
204 KB |
ans=YES N=5 |
5 |
Correct |
0 ms |
204 KB |
ans=YES N=9 |
6 |
Correct |
0 ms |
292 KB |
ans=YES N=5 |
7 |
Correct |
1 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 |
1 ms |
204 KB |
ans=YES N=10 |
12 |
Correct |
1 ms |
204 KB |
ans=YES N=9 |
13 |
Correct |
0 ms |
204 KB |
ans=YES N=9 |
14 |
Correct |
1 ms |
204 KB |
ans=YES N=8 |
15 |
Correct |
1 ms |
204 KB |
ans=YES N=8 |
16 |
Correct |
2 ms |
204 KB |
ans=NO N=2 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
ans=YES N=1 |
2 |
Correct |
0 ms |
204 KB |
ans=YES N=4 |
3 |
Correct |
1 ms |
204 KB |
ans=NO N=4 |
4 |
Correct |
0 ms |
204 KB |
ans=YES N=5 |
5 |
Correct |
0 ms |
204 KB |
ans=YES N=9 |
6 |
Correct |
0 ms |
292 KB |
ans=YES N=5 |
7 |
Correct |
1 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 |
1 ms |
204 KB |
ans=YES N=10 |
12 |
Correct |
1 ms |
204 KB |
ans=YES N=9 |
13 |
Correct |
0 ms |
204 KB |
ans=YES N=9 |
14 |
Correct |
1 ms |
204 KB |
ans=YES N=8 |
15 |
Correct |
1 ms |
204 KB |
ans=YES N=8 |
16 |
Correct |
2 ms |
204 KB |
ans=NO N=2 |
17 |
Correct |
1 ms |
204 KB |
ans=YES N=17 |
18 |
Correct |
1 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 |
332 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 |
1 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 |
Incorrect |
1 ms |
204 KB |
Added cell 151 (-866175210,267653108) not reachable from infinity |
38 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
ans=YES N=1 |
2 |
Correct |
0 ms |
204 KB |
ans=YES N=4 |
3 |
Correct |
1 ms |
204 KB |
ans=NO N=4 |
4 |
Correct |
0 ms |
204 KB |
ans=YES N=5 |
5 |
Correct |
0 ms |
204 KB |
ans=YES N=9 |
6 |
Correct |
0 ms |
292 KB |
ans=YES N=5 |
7 |
Correct |
1 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 |
1 ms |
204 KB |
ans=YES N=10 |
12 |
Correct |
1 ms |
204 KB |
ans=YES N=9 |
13 |
Correct |
0 ms |
204 KB |
ans=YES N=9 |
14 |
Correct |
1 ms |
204 KB |
ans=YES N=8 |
15 |
Correct |
1 ms |
204 KB |
ans=YES N=8 |
16 |
Correct |
2 ms |
204 KB |
ans=NO N=2 |
17 |
Correct |
1 ms |
204 KB |
ans=YES N=17 |
18 |
Correct |
1 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 |
332 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 |
1 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 |
Incorrect |
1 ms |
204 KB |
Added cell 151 (-866175210,267653108) not reachable from infinity |
38 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
364 KB |
ans=NO N=1934 |
2 |
Correct |
2 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 |
1 ms |
204 KB |
ans=YES N=1 |
2 |
Correct |
0 ms |
204 KB |
ans=YES N=4 |
3 |
Correct |
1 ms |
204 KB |
ans=NO N=4 |
4 |
Correct |
0 ms |
204 KB |
ans=YES N=5 |
5 |
Correct |
0 ms |
204 KB |
ans=YES N=9 |
6 |
Correct |
0 ms |
292 KB |
ans=YES N=5 |
7 |
Correct |
1 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 |
1 ms |
204 KB |
ans=YES N=10 |
12 |
Correct |
1 ms |
204 KB |
ans=YES N=9 |
13 |
Correct |
0 ms |
204 KB |
ans=YES N=9 |
14 |
Correct |
1 ms |
204 KB |
ans=YES N=8 |
15 |
Correct |
1 ms |
204 KB |
ans=YES N=8 |
16 |
Correct |
2 ms |
204 KB |
ans=NO N=2 |
17 |
Correct |
1 ms |
204 KB |
ans=YES N=17 |
18 |
Correct |
1 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 |
332 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 |
1 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 |
Incorrect |
1 ms |
204 KB |
Added cell 151 (-866175210,267653108) not reachable from infinity |
38 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
146 ms |
9488 KB |
ans=NO N=66151 |
2 |
Correct |
45 ms |
4784 KB |
ans=NO N=64333 |
3 |
Incorrect |
199 ms |
10184 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 |
364 KB |
ans=NO N=1934 |
2 |
Correct |
2 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 |
- |