#include <bits/stdc++.h>
using namespace std;
const int dx[] = {0, 0, 1, 1, 1, -1, -1, -1};
const int dy[] = {1, -1, 1, -1, 0, 1, -1, 0};
int main() {
int n; scanf("%d", &n);
int t; scanf("%d", &t);
if(t == 2) return 0; // return to this subtask after coding t = 1
vector<pair<int,int>> sk(n);
for(auto& [x, y] : sk)
scanf("%d %d", &x, &y);
map<pair<int,int>, int> id;
for(int i = 0; i < n; i++)
id[sk[i]] = i+1;
sort(sk.begin(), sk.end());
set<pair<int,int>> mark;
priority_queue<pair<int,int>> q;
q.push(sk.back());
vector<int> ans;
while(q.size()) {
ans.push_back(id[q.top()]);
auto [x, y] = q.top();
mark.insert(q.top());
q.pop();
for(int k = 0; k < 8; k++)
if(binary_search(sk.begin(), sk.end(), pair<int,int>(x+dx[k], y+dy[k])) && !mark.count(pair<int,int>(x+dx[k], y+dy[k])))
q.push(pair<int,int>(x+dx[k], y+dy[k]));
}
if(ans.size() == n) {
puts("YES");
for(int x : ans)
printf("%d\n", x);
} else {
assert(0);
// puts("NO");
}
}
Compilation message
skyscrapers.cpp: In function 'int main()':
skyscrapers.cpp:41:19: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
41 | if(ans.size() == n) {
| ~~~~~~~~~~~^~~~
skyscrapers.cpp:8:17: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
8 | int n; scanf("%d", &n);
| ~~~~~^~~~~~~~~~
skyscrapers.cpp:9:17: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
9 | int t; scanf("%d", &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);
| ~~~~~^~~~~~~~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
ans=YES N=1 |
2 |
Runtime error |
1 ms |
340 KB |
Execution killed with signal 6 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
ans=YES N=1 |
2 |
Runtime error |
1 ms |
340 KB |
Execution killed with signal 6 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
ans=YES N=1 |
2 |
Runtime error |
1 ms |
340 KB |
Execution killed with signal 6 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Unexpected end of file - token expected |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
ans=YES N=1 |
2 |
Runtime error |
1 ms |
340 KB |
Execution killed with signal 6 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Unexpected end of file - token expected |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Unexpected end of file - token expected |
2 |
Halted |
0 ms |
0 KB |
- |