#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define int long long
typedef long long ll;
const int M = 2e7 + 5, MOD = 1e9+7;
int vis[M], cnt;
vector<int> node[M];
struct point {int x, y, i;};
vector<int> ans;
void bfs(int s) {
queue<int> q;
q.push(s);
vis[s] = true;
while (!q.empty()) {
int t = q.front();
cnt++;
q.pop();
ans.push_back(t);
for (int i:node[t]) {
if (!vis[i]) {
vis[i] = true;
q.push(i);
}
}
}
}
signed main() {
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
srand(time(0));
int n, t;
cin >> n >> t;
vector<point> v(n);
for (auto&i:v) cin >> i.x >> i.y;
int ind = 1; for (auto&i:v) i.i = ind++;
vector<point> p;
sort(v.begin(), v.end(), [](point a, point b){if (a.y == b.y) return a.x < b.x; return a.y < b.y;});
for (int i = 0; i < n; i++) {
while (i < n && (!i || v[i].y == v[i-1].y)) {
p.push_back(v[i++]);
}
for (int j = 1; j < p.size(); j++) {
if (p[j-1].x+1 == p[j].x) {
node[p[j].i].push_back(p[j-1].i);
node[p[j-1].i].push_back(p[j].i);
}
}
p.clear();
p.push_back(v[i]);
}
p.clear();
sort(v.begin(), v.end(), [](point a, point b){if (a.x == b.x) return a.y < b.y; return a.x < b.x;});
for (int i = 0; i < n; i++) {
while (i < n && (!i || v[i].x == v[i-1].x)) {
p.push_back(v[i++]);
}
for (int j = 1; j < p.size(); j++) {
if (p[j-1].y+1 == p[j].y) {
node[p[j].i].push_back(p[j-1].i);
node[p[j-1].i].push_back(p[j].i);
}
}
p.clear();
p.push_back(v[i]);
}
p.clear();
sort(v.begin(), v.end(), [](point a, point b){if ((a.x+a.y) == (b.x+b.y)) return a.x < b.x; return a.x+a.y < b.x+b.y;});
for (int i = 0; i < n; i++) {
while (i < n && (!i || (v[i].x+v[i].y) == (v[i-1].x+v[i-1].y))) {
p.push_back(v[i++]);
}
for (int j = 1; j < p.size(); j++) {
if (p[j-1].x+1 == p[j].x) {
node[p[j].i].push_back(p[j-1].i);
node[p[j-1].i].push_back(p[j].i);
}
}
p.clear();
p.push_back(v[i]);
}
p.clear();
sort(v.begin(), v.end(), [](point a, point b){if ((a.x-a.y) == (b.x-b.y)) return a.x < b.x; return a.x-a.y < b.x-b.y;});
for (int i = 0; i < n; i++) {
while (i < n && (!i || (v[i].x-v[i].y) == (v[i-1].x-v[i-1].y))) {
p.push_back(v[i++]);
}
for (int j = 1; j < p.size(); j++) {
if (p[j-1].x+1 == p[j].x) {
node[p[j].i].push_back(p[j-1].i);
node[p[j-1].i].push_back(p[j].i);
}
}
p.clear();
p.push_back(v[i]);
}
bfs(n);
if (cnt == n) {
cout << "YES" << endl;
for (int i:ans) cout << i << endl;
} else cout << "NO" << endl;
return 0;
}
/*
3 2
0 0
0 1
0 2
*/
Compilation message
skyscrapers.cpp: In function 'int main()':
skyscrapers.cpp:49:27: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<point>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
49 | for (int j = 1; j < p.size(); j++) {
| ~~^~~~~~~~~~
skyscrapers.cpp:67:27: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<point>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
67 | for (int j = 1; j < p.size(); j++) {
| ~~^~~~~~~~~~
skyscrapers.cpp:85:27: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<point>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
85 | for (int j = 1; j < p.size(); j++) {
| ~~^~~~~~~~~~
skyscrapers.cpp:103:27: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<point>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
103 | for (int j = 1; j < p.size(); j++) {
| ~~^~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
209 ms |
470068 KB |
ans=YES N=1 |
2 |
Correct |
208 ms |
469920 KB |
ans=YES N=4 |
3 |
Correct |
211 ms |
470068 KB |
ans=NO N=4 |
4 |
Correct |
210 ms |
469964 KB |
ans=YES N=5 |
5 |
Correct |
209 ms |
469964 KB |
ans=YES N=9 |
6 |
Correct |
226 ms |
469940 KB |
ans=YES N=5 |
7 |
Correct |
208 ms |
469972 KB |
ans=NO N=9 |
8 |
Correct |
210 ms |
469968 KB |
ans=NO N=10 |
9 |
Correct |
210 ms |
469924 KB |
ans=YES N=10 |
10 |
Correct |
211 ms |
469920 KB |
ans=YES N=10 |
11 |
Correct |
233 ms |
469968 KB |
ans=YES N=10 |
12 |
Correct |
205 ms |
469968 KB |
ans=YES N=9 |
13 |
Correct |
208 ms |
469896 KB |
ans=YES N=9 |
14 |
Correct |
207 ms |
469976 KB |
ans=YES N=8 |
15 |
Correct |
206 ms |
469888 KB |
ans=YES N=8 |
16 |
Correct |
228 ms |
469880 KB |
ans=NO N=2 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
209 ms |
470068 KB |
ans=YES N=1 |
2 |
Correct |
208 ms |
469920 KB |
ans=YES N=4 |
3 |
Correct |
211 ms |
470068 KB |
ans=NO N=4 |
4 |
Correct |
210 ms |
469964 KB |
ans=YES N=5 |
5 |
Correct |
209 ms |
469964 KB |
ans=YES N=9 |
6 |
Correct |
226 ms |
469940 KB |
ans=YES N=5 |
7 |
Correct |
208 ms |
469972 KB |
ans=NO N=9 |
8 |
Correct |
210 ms |
469968 KB |
ans=NO N=10 |
9 |
Correct |
210 ms |
469924 KB |
ans=YES N=10 |
10 |
Correct |
211 ms |
469920 KB |
ans=YES N=10 |
11 |
Correct |
233 ms |
469968 KB |
ans=YES N=10 |
12 |
Correct |
205 ms |
469968 KB |
ans=YES N=9 |
13 |
Correct |
208 ms |
469896 KB |
ans=YES N=9 |
14 |
Correct |
207 ms |
469976 KB |
ans=YES N=8 |
15 |
Correct |
206 ms |
469888 KB |
ans=YES N=8 |
16 |
Correct |
228 ms |
469880 KB |
ans=NO N=2 |
17 |
Correct |
209 ms |
469860 KB |
ans=YES N=17 |
18 |
Correct |
208 ms |
469904 KB |
ans=YES N=25 |
19 |
Correct |
211 ms |
469928 KB |
ans=YES N=100 |
20 |
Correct |
213 ms |
469920 KB |
ans=YES N=185 |
21 |
Correct |
210 ms |
469976 KB |
ans=NO N=174 |
22 |
Correct |
211 ms |
469992 KB |
ans=YES N=90 |
23 |
Correct |
206 ms |
469876 KB |
ans=YES N=63 |
24 |
Correct |
209 ms |
469896 KB |
ans=YES N=87 |
25 |
Correct |
212 ms |
470020 KB |
ans=YES N=183 |
26 |
Correct |
210 ms |
469892 KB |
ans=YES N=188 |
27 |
Correct |
208 ms |
469964 KB |
ans=YES N=183 |
28 |
Correct |
208 ms |
469940 KB |
ans=YES N=189 |
29 |
Correct |
209 ms |
469964 KB |
ans=YES N=200 |
30 |
Correct |
217 ms |
469912 KB |
ans=YES N=190 |
31 |
Correct |
213 ms |
470000 KB |
ans=YES N=187 |
32 |
Correct |
209 ms |
469956 KB |
ans=YES N=187 |
33 |
Correct |
208 ms |
470008 KB |
ans=YES N=182 |
34 |
Correct |
209 ms |
469992 KB |
ans=YES N=184 |
35 |
Correct |
218 ms |
469916 KB |
ans=YES N=188 |
36 |
Correct |
209 ms |
469980 KB |
ans=YES N=181 |
37 |
Correct |
216 ms |
469900 KB |
ans=YES N=188 |
38 |
Correct |
211 ms |
470008 KB |
ans=YES N=191 |
39 |
Incorrect |
214 ms |
469992 KB |
Added cell 196 (16,2) not reachable from infinity |
40 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
209 ms |
470068 KB |
ans=YES N=1 |
2 |
Correct |
208 ms |
469920 KB |
ans=YES N=4 |
3 |
Correct |
211 ms |
470068 KB |
ans=NO N=4 |
4 |
Correct |
210 ms |
469964 KB |
ans=YES N=5 |
5 |
Correct |
209 ms |
469964 KB |
ans=YES N=9 |
6 |
Correct |
226 ms |
469940 KB |
ans=YES N=5 |
7 |
Correct |
208 ms |
469972 KB |
ans=NO N=9 |
8 |
Correct |
210 ms |
469968 KB |
ans=NO N=10 |
9 |
Correct |
210 ms |
469924 KB |
ans=YES N=10 |
10 |
Correct |
211 ms |
469920 KB |
ans=YES N=10 |
11 |
Correct |
233 ms |
469968 KB |
ans=YES N=10 |
12 |
Correct |
205 ms |
469968 KB |
ans=YES N=9 |
13 |
Correct |
208 ms |
469896 KB |
ans=YES N=9 |
14 |
Correct |
207 ms |
469976 KB |
ans=YES N=8 |
15 |
Correct |
206 ms |
469888 KB |
ans=YES N=8 |
16 |
Correct |
228 ms |
469880 KB |
ans=NO N=2 |
17 |
Correct |
209 ms |
469860 KB |
ans=YES N=17 |
18 |
Correct |
208 ms |
469904 KB |
ans=YES N=25 |
19 |
Correct |
211 ms |
469928 KB |
ans=YES N=100 |
20 |
Correct |
213 ms |
469920 KB |
ans=YES N=185 |
21 |
Correct |
210 ms |
469976 KB |
ans=NO N=174 |
22 |
Correct |
211 ms |
469992 KB |
ans=YES N=90 |
23 |
Correct |
206 ms |
469876 KB |
ans=YES N=63 |
24 |
Correct |
209 ms |
469896 KB |
ans=YES N=87 |
25 |
Correct |
212 ms |
470020 KB |
ans=YES N=183 |
26 |
Correct |
210 ms |
469892 KB |
ans=YES N=188 |
27 |
Correct |
208 ms |
469964 KB |
ans=YES N=183 |
28 |
Correct |
208 ms |
469940 KB |
ans=YES N=189 |
29 |
Correct |
209 ms |
469964 KB |
ans=YES N=200 |
30 |
Correct |
217 ms |
469912 KB |
ans=YES N=190 |
31 |
Correct |
213 ms |
470000 KB |
ans=YES N=187 |
32 |
Correct |
209 ms |
469956 KB |
ans=YES N=187 |
33 |
Correct |
208 ms |
470008 KB |
ans=YES N=182 |
34 |
Correct |
209 ms |
469992 KB |
ans=YES N=184 |
35 |
Correct |
218 ms |
469916 KB |
ans=YES N=188 |
36 |
Correct |
209 ms |
469980 KB |
ans=YES N=181 |
37 |
Correct |
216 ms |
469900 KB |
ans=YES N=188 |
38 |
Correct |
211 ms |
470008 KB |
ans=YES N=191 |
39 |
Incorrect |
214 ms |
469992 KB |
Added cell 196 (16,2) not reachable from infinity |
40 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
212 ms |
470024 KB |
ans=NO N=1934 |
2 |
Correct |
223 ms |
470092 KB |
ans=NO N=1965 |
3 |
Incorrect |
210 ms |
470200 KB |
Contestant's solution is not lexicographically largest at index 1824 (1813 vs 974) |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
209 ms |
470068 KB |
ans=YES N=1 |
2 |
Correct |
208 ms |
469920 KB |
ans=YES N=4 |
3 |
Correct |
211 ms |
470068 KB |
ans=NO N=4 |
4 |
Correct |
210 ms |
469964 KB |
ans=YES N=5 |
5 |
Correct |
209 ms |
469964 KB |
ans=YES N=9 |
6 |
Correct |
226 ms |
469940 KB |
ans=YES N=5 |
7 |
Correct |
208 ms |
469972 KB |
ans=NO N=9 |
8 |
Correct |
210 ms |
469968 KB |
ans=NO N=10 |
9 |
Correct |
210 ms |
469924 KB |
ans=YES N=10 |
10 |
Correct |
211 ms |
469920 KB |
ans=YES N=10 |
11 |
Correct |
233 ms |
469968 KB |
ans=YES N=10 |
12 |
Correct |
205 ms |
469968 KB |
ans=YES N=9 |
13 |
Correct |
208 ms |
469896 KB |
ans=YES N=9 |
14 |
Correct |
207 ms |
469976 KB |
ans=YES N=8 |
15 |
Correct |
206 ms |
469888 KB |
ans=YES N=8 |
16 |
Correct |
228 ms |
469880 KB |
ans=NO N=2 |
17 |
Correct |
209 ms |
469860 KB |
ans=YES N=17 |
18 |
Correct |
208 ms |
469904 KB |
ans=YES N=25 |
19 |
Correct |
211 ms |
469928 KB |
ans=YES N=100 |
20 |
Correct |
213 ms |
469920 KB |
ans=YES N=185 |
21 |
Correct |
210 ms |
469976 KB |
ans=NO N=174 |
22 |
Correct |
211 ms |
469992 KB |
ans=YES N=90 |
23 |
Correct |
206 ms |
469876 KB |
ans=YES N=63 |
24 |
Correct |
209 ms |
469896 KB |
ans=YES N=87 |
25 |
Correct |
212 ms |
470020 KB |
ans=YES N=183 |
26 |
Correct |
210 ms |
469892 KB |
ans=YES N=188 |
27 |
Correct |
208 ms |
469964 KB |
ans=YES N=183 |
28 |
Correct |
208 ms |
469940 KB |
ans=YES N=189 |
29 |
Correct |
209 ms |
469964 KB |
ans=YES N=200 |
30 |
Correct |
217 ms |
469912 KB |
ans=YES N=190 |
31 |
Correct |
213 ms |
470000 KB |
ans=YES N=187 |
32 |
Correct |
209 ms |
469956 KB |
ans=YES N=187 |
33 |
Correct |
208 ms |
470008 KB |
ans=YES N=182 |
34 |
Correct |
209 ms |
469992 KB |
ans=YES N=184 |
35 |
Correct |
218 ms |
469916 KB |
ans=YES N=188 |
36 |
Correct |
209 ms |
469980 KB |
ans=YES N=181 |
37 |
Correct |
216 ms |
469900 KB |
ans=YES N=188 |
38 |
Correct |
211 ms |
470008 KB |
ans=YES N=191 |
39 |
Incorrect |
214 ms |
469992 KB |
Added cell 196 (16,2) not reachable from infinity |
40 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
269 ms |
478332 KB |
ans=NO N=66151 |
2 |
Correct |
243 ms |
472328 KB |
ans=NO N=64333 |
3 |
Incorrect |
274 ms |
479040 KB |
Contestant's solution is not lexicographically largest at index 69316 (69235 vs 6892) |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
212 ms |
470024 KB |
ans=NO N=1934 |
2 |
Correct |
223 ms |
470092 KB |
ans=NO N=1965 |
3 |
Incorrect |
210 ms |
470200 KB |
Contestant's solution is not lexicographically largest at index 1824 (1813 vs 974) |
4 |
Halted |
0 ms |
0 KB |
- |