#include <bits/stdc++.h>
using namespace std;
int n, T;
map <pair <int, int>, int> mp, vis;
int dx[8] = {0, 1, 0, -1, 1, -1, 1, -1};
int dy[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int main() {
// freopen("test.inp", "r", stdin);
ios :: sync_with_stdio(0); cin.tie(0);
cin >> n >> T;
vector <pair <int, int> > P;
int X = 0, Y = 0;
for (int i = 1; i <= n; ++i) {
int x, y;
cin >> x >> y;
mp[{x, y}] = i;
X = x, Y = y;
}
queue <pair <int, int> > q;
q.push({X, Y});
vis[{X, Y}] = 1;
vector <int> ans;
while (q.size()) {
int x = q.front().first;
int y = q.front().second;
ans.push_back(mp[{x, y}]);
q.pop();
for (int i = 0; i < 8; ++i) {
int u = x + dx[i];
int v = y + dy[i];
if (mp.find({u, v}) == mp.end() || vis[{u, v}]) continue;
vis[{u, v}] = 1;
q.push({u, v});
}
}
if (ans.size() != n) {
cout << "NO\n";
exit(0);
}
cout << "YES\n";
for (int i = 0; i < ans.size(); ++i) cout << ans[i] << '\n';
}
Compilation message
skyscrapers.cpp: In function 'int main()':
skyscrapers.cpp:40:20: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
40 | if (ans.size() != n) {
| ~~~~~~~~~~~^~~~
skyscrapers.cpp:45:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
45 | for (int i = 0; i < ans.size(); ++i) cout << ans[i] << '\n';
| ~~^~~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
ans=YES N=1 |
2 |
Correct |
1 ms |
212 KB |
ans=YES N=4 |
3 |
Correct |
1 ms |
212 KB |
ans=NO N=4 |
4 |
Correct |
0 ms |
212 KB |
ans=YES N=5 |
5 |
Correct |
0 ms |
320 KB |
ans=YES N=9 |
6 |
Correct |
1 ms |
212 KB |
ans=YES N=5 |
7 |
Correct |
0 ms |
212 KB |
ans=NO N=9 |
8 |
Correct |
1 ms |
320 KB |
ans=NO N=10 |
9 |
Correct |
1 ms |
212 KB |
ans=YES N=10 |
10 |
Correct |
1 ms |
212 KB |
ans=YES N=10 |
11 |
Correct |
0 ms |
212 KB |
ans=YES N=10 |
12 |
Correct |
1 ms |
212 KB |
ans=YES N=9 |
13 |
Correct |
0 ms |
212 KB |
ans=YES N=9 |
14 |
Correct |
0 ms |
212 KB |
ans=YES N=8 |
15 |
Correct |
1 ms |
212 KB |
ans=YES N=8 |
16 |
Correct |
0 ms |
212 KB |
ans=NO N=2 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
ans=YES N=1 |
2 |
Correct |
1 ms |
212 KB |
ans=YES N=4 |
3 |
Correct |
1 ms |
212 KB |
ans=NO N=4 |
4 |
Correct |
0 ms |
212 KB |
ans=YES N=5 |
5 |
Correct |
0 ms |
320 KB |
ans=YES N=9 |
6 |
Correct |
1 ms |
212 KB |
ans=YES N=5 |
7 |
Correct |
0 ms |
212 KB |
ans=NO N=9 |
8 |
Correct |
1 ms |
320 KB |
ans=NO N=10 |
9 |
Correct |
1 ms |
212 KB |
ans=YES N=10 |
10 |
Correct |
1 ms |
212 KB |
ans=YES N=10 |
11 |
Correct |
0 ms |
212 KB |
ans=YES N=10 |
12 |
Correct |
1 ms |
212 KB |
ans=YES N=9 |
13 |
Correct |
0 ms |
212 KB |
ans=YES N=9 |
14 |
Correct |
0 ms |
212 KB |
ans=YES N=8 |
15 |
Correct |
1 ms |
212 KB |
ans=YES N=8 |
16 |
Correct |
0 ms |
212 KB |
ans=NO N=2 |
17 |
Correct |
1 ms |
212 KB |
ans=YES N=17 |
18 |
Correct |
1 ms |
212 KB |
ans=YES N=25 |
19 |
Correct |
1 ms |
212 KB |
ans=YES N=100 |
20 |
Correct |
1 ms |
328 KB |
ans=YES N=185 |
21 |
Correct |
1 ms |
316 KB |
ans=NO N=174 |
22 |
Correct |
1 ms |
212 KB |
ans=YES N=90 |
23 |
Correct |
1 ms |
316 KB |
ans=YES N=63 |
24 |
Correct |
1 ms |
212 KB |
ans=YES N=87 |
25 |
Correct |
1 ms |
320 KB |
ans=YES N=183 |
26 |
Correct |
1 ms |
340 KB |
ans=YES N=188 |
27 |
Correct |
1 ms |
340 KB |
ans=YES N=183 |
28 |
Correct |
1 ms |
340 KB |
ans=YES N=189 |
29 |
Correct |
1 ms |
340 KB |
ans=YES N=200 |
30 |
Correct |
1 ms |
340 KB |
ans=YES N=190 |
31 |
Correct |
1 ms |
324 KB |
ans=YES N=187 |
32 |
Correct |
1 ms |
340 KB |
ans=YES N=187 |
33 |
Correct |
1 ms |
340 KB |
ans=YES N=182 |
34 |
Correct |
1 ms |
320 KB |
ans=YES N=184 |
35 |
Correct |
1 ms |
340 KB |
ans=YES N=188 |
36 |
Correct |
1 ms |
340 KB |
ans=YES N=181 |
37 |
Correct |
1 ms |
340 KB |
ans=YES N=188 |
38 |
Correct |
1 ms |
340 KB |
ans=YES N=191 |
39 |
Incorrect |
1 ms |
340 KB |
Added cell 196 (16,2) not reachable from infinity |
40 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
ans=YES N=1 |
2 |
Correct |
1 ms |
212 KB |
ans=YES N=4 |
3 |
Correct |
1 ms |
212 KB |
ans=NO N=4 |
4 |
Correct |
0 ms |
212 KB |
ans=YES N=5 |
5 |
Correct |
0 ms |
320 KB |
ans=YES N=9 |
6 |
Correct |
1 ms |
212 KB |
ans=YES N=5 |
7 |
Correct |
0 ms |
212 KB |
ans=NO N=9 |
8 |
Correct |
1 ms |
320 KB |
ans=NO N=10 |
9 |
Correct |
1 ms |
212 KB |
ans=YES N=10 |
10 |
Correct |
1 ms |
212 KB |
ans=YES N=10 |
11 |
Correct |
0 ms |
212 KB |
ans=YES N=10 |
12 |
Correct |
1 ms |
212 KB |
ans=YES N=9 |
13 |
Correct |
0 ms |
212 KB |
ans=YES N=9 |
14 |
Correct |
0 ms |
212 KB |
ans=YES N=8 |
15 |
Correct |
1 ms |
212 KB |
ans=YES N=8 |
16 |
Correct |
0 ms |
212 KB |
ans=NO N=2 |
17 |
Correct |
1 ms |
212 KB |
ans=YES N=17 |
18 |
Correct |
1 ms |
212 KB |
ans=YES N=25 |
19 |
Correct |
1 ms |
212 KB |
ans=YES N=100 |
20 |
Correct |
1 ms |
328 KB |
ans=YES N=185 |
21 |
Correct |
1 ms |
316 KB |
ans=NO N=174 |
22 |
Correct |
1 ms |
212 KB |
ans=YES N=90 |
23 |
Correct |
1 ms |
316 KB |
ans=YES N=63 |
24 |
Correct |
1 ms |
212 KB |
ans=YES N=87 |
25 |
Correct |
1 ms |
320 KB |
ans=YES N=183 |
26 |
Correct |
1 ms |
340 KB |
ans=YES N=188 |
27 |
Correct |
1 ms |
340 KB |
ans=YES N=183 |
28 |
Correct |
1 ms |
340 KB |
ans=YES N=189 |
29 |
Correct |
1 ms |
340 KB |
ans=YES N=200 |
30 |
Correct |
1 ms |
340 KB |
ans=YES N=190 |
31 |
Correct |
1 ms |
324 KB |
ans=YES N=187 |
32 |
Correct |
1 ms |
340 KB |
ans=YES N=187 |
33 |
Correct |
1 ms |
340 KB |
ans=YES N=182 |
34 |
Correct |
1 ms |
320 KB |
ans=YES N=184 |
35 |
Correct |
1 ms |
340 KB |
ans=YES N=188 |
36 |
Correct |
1 ms |
340 KB |
ans=YES N=181 |
37 |
Correct |
1 ms |
340 KB |
ans=YES N=188 |
38 |
Correct |
1 ms |
340 KB |
ans=YES N=191 |
39 |
Incorrect |
1 ms |
340 KB |
Added cell 196 (16,2) not reachable from infinity |
40 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
468 KB |
ans=NO N=1934 |
2 |
Correct |
1 ms |
340 KB |
ans=NO N=1965 |
3 |
Incorrect |
3 ms |
468 KB |
Contestant's solution is not lexicographically largest at index 1824 (1813 vs 974) |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
ans=YES N=1 |
2 |
Correct |
1 ms |
212 KB |
ans=YES N=4 |
3 |
Correct |
1 ms |
212 KB |
ans=NO N=4 |
4 |
Correct |
0 ms |
212 KB |
ans=YES N=5 |
5 |
Correct |
0 ms |
320 KB |
ans=YES N=9 |
6 |
Correct |
1 ms |
212 KB |
ans=YES N=5 |
7 |
Correct |
0 ms |
212 KB |
ans=NO N=9 |
8 |
Correct |
1 ms |
320 KB |
ans=NO N=10 |
9 |
Correct |
1 ms |
212 KB |
ans=YES N=10 |
10 |
Correct |
1 ms |
212 KB |
ans=YES N=10 |
11 |
Correct |
0 ms |
212 KB |
ans=YES N=10 |
12 |
Correct |
1 ms |
212 KB |
ans=YES N=9 |
13 |
Correct |
0 ms |
212 KB |
ans=YES N=9 |
14 |
Correct |
0 ms |
212 KB |
ans=YES N=8 |
15 |
Correct |
1 ms |
212 KB |
ans=YES N=8 |
16 |
Correct |
0 ms |
212 KB |
ans=NO N=2 |
17 |
Correct |
1 ms |
212 KB |
ans=YES N=17 |
18 |
Correct |
1 ms |
212 KB |
ans=YES N=25 |
19 |
Correct |
1 ms |
212 KB |
ans=YES N=100 |
20 |
Correct |
1 ms |
328 KB |
ans=YES N=185 |
21 |
Correct |
1 ms |
316 KB |
ans=NO N=174 |
22 |
Correct |
1 ms |
212 KB |
ans=YES N=90 |
23 |
Correct |
1 ms |
316 KB |
ans=YES N=63 |
24 |
Correct |
1 ms |
212 KB |
ans=YES N=87 |
25 |
Correct |
1 ms |
320 KB |
ans=YES N=183 |
26 |
Correct |
1 ms |
340 KB |
ans=YES N=188 |
27 |
Correct |
1 ms |
340 KB |
ans=YES N=183 |
28 |
Correct |
1 ms |
340 KB |
ans=YES N=189 |
29 |
Correct |
1 ms |
340 KB |
ans=YES N=200 |
30 |
Correct |
1 ms |
340 KB |
ans=YES N=190 |
31 |
Correct |
1 ms |
324 KB |
ans=YES N=187 |
32 |
Correct |
1 ms |
340 KB |
ans=YES N=187 |
33 |
Correct |
1 ms |
340 KB |
ans=YES N=182 |
34 |
Correct |
1 ms |
320 KB |
ans=YES N=184 |
35 |
Correct |
1 ms |
340 KB |
ans=YES N=188 |
36 |
Correct |
1 ms |
340 KB |
ans=YES N=181 |
37 |
Correct |
1 ms |
340 KB |
ans=YES N=188 |
38 |
Correct |
1 ms |
340 KB |
ans=YES N=191 |
39 |
Incorrect |
1 ms |
340 KB |
Added cell 196 (16,2) not reachable from infinity |
40 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
160 ms |
9480 KB |
ans=NO N=66151 |
2 |
Correct |
33 ms |
4776 KB |
ans=NO N=64333 |
3 |
Incorrect |
183 ms |
10140 KB |
Contestant's solution is not lexicographically largest at index 69316 (69235 vs 6892) |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
468 KB |
ans=NO N=1934 |
2 |
Correct |
1 ms |
340 KB |
ans=NO N=1965 |
3 |
Incorrect |
3 ms |
468 KB |
Contestant's solution is not lexicographically largest at index 1824 (1813 vs 974) |
4 |
Halted |
0 ms |
0 KB |
- |