#include <bits/stdc++.h>
using namespace std;
int n,t;
typedef pair<int,int> P;
set<P> s;
map<P,int> mp;
int dx[8]={1,1,0,-1,-1,-1,0,1};
int dy[8]={0,1,1,1,0,-1,-1,-1};
int main() {
scanf("%d %d",&n,&t);
for(int i=0;i<n;i++) {
int x,y;
scanf("%d %d",&x,&y);
s.insert(P(x,y));
mp[P(x,y)]=i+1;
}
P now=*s.begin();
s.erase(now);
priority_queue<P,vector<P>,greater<P>> pq;
pq.push(now);
vector<int> ret;
while (!pq.empty()) {
P now=pq.top();
pq.pop();
ret.push_back(mp[P(now.first,now.second)]);
for(int i=0;i<4;i++) {
int x=now.first+dx[i];
int y=now.second+dy[i];
if (s.find(P(x,y))!=s.end()) {
s.erase(P(x,y));
pq.push(P(x,y));
}
}
}
if (ret.size()!=n) {
printf("NO");
return 0;
}
printf("YES\n");
for(int i=0;i<n;i++) {
printf("%d\n",ret[i]);
}
return 0;
}
Compilation message
skyscrapers.cpp: In function 'int main()':
skyscrapers.cpp:37:19: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
37 | if (ret.size()!=n) {
| ~~~~~~~~~~^~~
skyscrapers.cpp:12:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
12 | scanf("%d %d",&n,&t);
| ~~~~~^~~~~~~~~~~~~~~
skyscrapers.cpp:15:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
15 | scanf("%d %d",&x,&y);
| ~~~~~^~~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
ans=YES N=1 |
2 |
Correct |
0 ms |
212 KB |
ans=YES N=4 |
3 |
Correct |
1 ms |
212 KB |
ans=NO N=4 |
4 |
Incorrect |
0 ms |
212 KB |
Contestant did not find solution |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
ans=YES N=1 |
2 |
Correct |
0 ms |
212 KB |
ans=YES N=4 |
3 |
Correct |
1 ms |
212 KB |
ans=NO N=4 |
4 |
Incorrect |
0 ms |
212 KB |
Contestant did not find solution |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
ans=YES N=1 |
2 |
Correct |
0 ms |
212 KB |
ans=YES N=4 |
3 |
Correct |
1 ms |
212 KB |
ans=NO N=4 |
4 |
Incorrect |
0 ms |
212 KB |
Contestant did not find solution |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
468 KB |
ans=NO N=1934 |
2 |
Correct |
1 ms |
468 KB |
ans=NO N=1965 |
3 |
Incorrect |
2 ms |
468 KB |
Contestant did not find solution |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
ans=YES N=1 |
2 |
Correct |
0 ms |
212 KB |
ans=YES N=4 |
3 |
Correct |
1 ms |
212 KB |
ans=NO N=4 |
4 |
Incorrect |
0 ms |
212 KB |
Contestant did not find solution |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
87 ms |
7892 KB |
ans=NO N=66151 |
2 |
Correct |
65 ms |
7332 KB |
ans=NO N=64333 |
3 |
Incorrect |
85 ms |
8244 KB |
Contestant did not find solution |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
468 KB |
ans=NO N=1934 |
2 |
Correct |
1 ms |
468 KB |
ans=NO N=1965 |
3 |
Incorrect |
2 ms |
468 KB |
Contestant did not find solution |
4 |
Halted |
0 ms |
0 KB |
- |