#include <bits/stdc++.h>
#include <fstream>
#define endl '\n'
#define mod 32768
#define INF 100000000000000
//#define ll long long
//#define cin fin
//#define cout fout
using namespace std;
//ofstream fout("convention.out");
//ifstream fin("convention.in");
int main()
{
ios_base::sync_with_stdio(0);cout.tie(0);cin.tie(0);
int n, t;
cin >> n >> t;
map<pair<long long,long long>,long long> mp;
long long cnt = 1;
bool check[n+1] = {};
vector<int> ans;
priority_queue<pair<long long,long long>> pq;
for(int i = 0; i < n; i++)
{
long long a, b;
cin >> a >> b;
if(i == 0)
{
pq.push({a,b});
}
mp[{a,b}] = cnt;
cnt++;
}
while(!pq.empty())
{
pair<long long ,long long> tp = pq.top();
long long x = tp.first, y = tp.second;
ans.push_back(mp[{x,y}]);
check[mp[{x,y}]] = 1;
pq.pop();
if(mp[{x+1,y}] > 0 && check[mp[{x+1,y}]] == 0)
{
pq.push({x+1,y});
check[mp[{x+1,y}]] = 1;
}
if(mp[{x-1,y}] > 0 && check[mp[{x-1,y}]] == 0)
{
pq.push({x-1,y});
check[mp[{x-1,y}]] = 1;
}
if(mp[{x,y+1}] > 0 && check[mp[{x,y+1}]] == 0)
{
pq.push({x,y+1});
check[mp[{x,y+1}]] = 1;
}
if(mp[{x,y-1}] > 0 && check[mp[{x,y-1}]] == 0)
{
pq.push({x,y-1});
check[mp[{x,y-1}]] = 1;
}
if(mp[{x+1,y+1}] > 0 && check[mp[{x+1,y+1}]] == 0)
{
pq.push({x+1,y+1});
check[mp[{x+1,y+1}]] = 1;
}
if(mp[{x-1,y-1}] > 0 && check[mp[{x-1,y-1}]] == 0)
{
pq.push({x-1,y-1});
check[mp[{x-1,y-1}]] = 1;
}
if(mp[{x-1,y+1}] > 0 && check[mp[{x-1,y+1}]] == 0)
{
pq.push({x-1,y+1});
check[mp[{x-1,y+1}]] = 1;
}
if(mp[{x+1,y-1}] > 0 && check[mp[{x+1,y-1}]] == 0)
{
pq.push({x+1,y-1});
check[mp[{x+1,y-1}]] = 1;
}
}
bool ok = true;
for(int i = 1; i <= n; i++)
{
if(check[i] == 0)
{
ok = false;
break;
}
}
if(ok)
{
cout << "YES" << endl;
for(int i = 0; i < ans.size(); i++)
cout << ans[i] << endl;
return 0;
}
cout << "NO" << endl;
return 0;
}
Compilation message
skyscrapers.cpp: In function 'int main()':
skyscrapers.cpp:95:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
95 | for(int i = 0; i < ans.size(); i++)
| ~~^~~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 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 |
1 ms |
212 KB |
ans=YES N=5 |
5 |
Correct |
1 ms |
212 KB |
ans=YES N=9 |
6 |
Correct |
1 ms |
212 KB |
ans=YES N=5 |
7 |
Correct |
1 ms |
320 KB |
ans=NO N=9 |
8 |
Correct |
1 ms |
212 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 |
1 ms |
212 KB |
ans=YES N=10 |
12 |
Correct |
1 ms |
212 KB |
ans=YES N=9 |
13 |
Correct |
1 ms |
324 KB |
ans=YES N=9 |
14 |
Correct |
1 ms |
212 KB |
ans=YES N=8 |
15 |
Correct |
0 ms |
320 KB |
ans=YES N=8 |
16 |
Correct |
1 ms |
212 KB |
ans=NO N=2 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 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 |
1 ms |
212 KB |
ans=YES N=5 |
5 |
Correct |
1 ms |
212 KB |
ans=YES N=9 |
6 |
Correct |
1 ms |
212 KB |
ans=YES N=5 |
7 |
Correct |
1 ms |
320 KB |
ans=NO N=9 |
8 |
Correct |
1 ms |
212 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 |
1 ms |
212 KB |
ans=YES N=10 |
12 |
Correct |
1 ms |
212 KB |
ans=YES N=9 |
13 |
Correct |
1 ms |
324 KB |
ans=YES N=9 |
14 |
Correct |
1 ms |
212 KB |
ans=YES N=8 |
15 |
Correct |
0 ms |
320 KB |
ans=YES N=8 |
16 |
Correct |
1 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 |
340 KB |
ans=YES N=185 |
21 |
Correct |
1 ms |
212 KB |
ans=NO N=174 |
22 |
Correct |
1 ms |
212 KB |
ans=YES N=90 |
23 |
Correct |
1 ms |
212 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 |
324 KB |
ans=YES N=188 |
27 |
Correct |
1 ms |
284 KB |
ans=YES N=183 |
28 |
Correct |
1 ms |
340 KB |
ans=YES N=189 |
29 |
Correct |
1 ms |
324 KB |
ans=YES N=200 |
30 |
Correct |
1 ms |
320 KB |
ans=YES N=190 |
31 |
Correct |
1 ms |
324 KB |
ans=YES N=187 |
32 |
Correct |
1 ms |
324 KB |
ans=YES N=187 |
33 |
Correct |
1 ms |
340 KB |
ans=YES N=182 |
34 |
Correct |
1 ms |
340 KB |
ans=YES N=184 |
35 |
Correct |
1 ms |
320 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 |
Correct |
1 ms |
340 KB |
ans=YES N=196 |
40 |
Correct |
1 ms |
340 KB |
ans=YES N=196 |
41 |
Correct |
1 ms |
340 KB |
ans=YES N=196 |
42 |
Correct |
1 ms |
340 KB |
ans=YES N=196 |
43 |
Correct |
1 ms |
340 KB |
ans=YES N=195 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 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 |
1 ms |
212 KB |
ans=YES N=5 |
5 |
Correct |
1 ms |
212 KB |
ans=YES N=9 |
6 |
Correct |
1 ms |
212 KB |
ans=YES N=5 |
7 |
Correct |
1 ms |
320 KB |
ans=NO N=9 |
8 |
Correct |
1 ms |
212 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 |
1 ms |
212 KB |
ans=YES N=10 |
12 |
Correct |
1 ms |
212 KB |
ans=YES N=9 |
13 |
Correct |
1 ms |
324 KB |
ans=YES N=9 |
14 |
Correct |
1 ms |
212 KB |
ans=YES N=8 |
15 |
Correct |
0 ms |
320 KB |
ans=YES N=8 |
16 |
Correct |
1 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 |
340 KB |
ans=YES N=185 |
21 |
Correct |
1 ms |
212 KB |
ans=NO N=174 |
22 |
Correct |
1 ms |
212 KB |
ans=YES N=90 |
23 |
Correct |
1 ms |
212 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 |
324 KB |
ans=YES N=188 |
27 |
Correct |
1 ms |
284 KB |
ans=YES N=183 |
28 |
Correct |
1 ms |
340 KB |
ans=YES N=189 |
29 |
Correct |
1 ms |
324 KB |
ans=YES N=200 |
30 |
Correct |
1 ms |
320 KB |
ans=YES N=190 |
31 |
Correct |
1 ms |
324 KB |
ans=YES N=187 |
32 |
Correct |
1 ms |
324 KB |
ans=YES N=187 |
33 |
Correct |
1 ms |
340 KB |
ans=YES N=182 |
34 |
Correct |
1 ms |
340 KB |
ans=YES N=184 |
35 |
Correct |
1 ms |
320 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 |
Correct |
1 ms |
340 KB |
ans=YES N=196 |
40 |
Correct |
1 ms |
340 KB |
ans=YES N=196 |
41 |
Correct |
1 ms |
340 KB |
ans=YES N=196 |
42 |
Correct |
1 ms |
340 KB |
ans=YES N=196 |
43 |
Correct |
1 ms |
340 KB |
ans=YES N=195 |
44 |
Correct |
2 ms |
468 KB |
ans=NO N=1934 |
45 |
Correct |
1 ms |
468 KB |
ans=NO N=1965 |
46 |
Correct |
4 ms |
464 KB |
ans=YES N=1824 |
47 |
Correct |
4 ms |
512 KB |
ans=YES N=1981 |
48 |
Correct |
5 ms |
468 KB |
ans=YES N=1814 |
49 |
Correct |
4 ms |
444 KB |
ans=YES N=1854 |
50 |
Correct |
4 ms |
468 KB |
ans=YES N=1831 |
51 |
Correct |
5 ms |
540 KB |
ans=YES N=2000 |
52 |
Correct |
4 ms |
596 KB |
ans=YES N=1847 |
53 |
Correct |
5 ms |
596 KB |
ans=YES N=1819 |
54 |
Correct |
5 ms |
468 KB |
ans=YES N=1986 |
55 |
Correct |
5 ms |
724 KB |
ans=YES N=2000 |
56 |
Correct |
5 ms |
724 KB |
ans=YES N=1834 |
57 |
Correct |
5 ms |
724 KB |
ans=YES N=1860 |
58 |
Correct |
6 ms |
724 KB |
ans=YES N=1898 |
59 |
Correct |
5 ms |
588 KB |
ans=YES N=1832 |
60 |
Correct |
4 ms |
852 KB |
ans=YES N=1929 |
61 |
Correct |
4 ms |
544 KB |
ans=YES N=1919 |
62 |
Correct |
5 ms |
712 KB |
ans=YES N=1882 |
63 |
Correct |
5 ms |
836 KB |
ans=YES N=1922 |
64 |
Correct |
4 ms |
468 KB |
ans=YES N=1989 |
65 |
Correct |
4 ms |
588 KB |
ans=YES N=1978 |
66 |
Correct |
5 ms |
596 KB |
ans=YES N=1867 |
67 |
Correct |
5 ms |
636 KB |
ans=YES N=1942 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
468 KB |
ans=NO N=1934 |
2 |
Correct |
2 ms |
468 KB |
ans=NO N=1965 |
3 |
Incorrect |
4 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 |
1 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 |
1 ms |
212 KB |
ans=YES N=5 |
5 |
Correct |
1 ms |
212 KB |
ans=YES N=9 |
6 |
Correct |
1 ms |
212 KB |
ans=YES N=5 |
7 |
Correct |
1 ms |
320 KB |
ans=NO N=9 |
8 |
Correct |
1 ms |
212 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 |
1 ms |
212 KB |
ans=YES N=10 |
12 |
Correct |
1 ms |
212 KB |
ans=YES N=9 |
13 |
Correct |
1 ms |
324 KB |
ans=YES N=9 |
14 |
Correct |
1 ms |
212 KB |
ans=YES N=8 |
15 |
Correct |
0 ms |
320 KB |
ans=YES N=8 |
16 |
Correct |
1 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 |
340 KB |
ans=YES N=185 |
21 |
Correct |
1 ms |
212 KB |
ans=NO N=174 |
22 |
Correct |
1 ms |
212 KB |
ans=YES N=90 |
23 |
Correct |
1 ms |
212 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 |
324 KB |
ans=YES N=188 |
27 |
Correct |
1 ms |
284 KB |
ans=YES N=183 |
28 |
Correct |
1 ms |
340 KB |
ans=YES N=189 |
29 |
Correct |
1 ms |
324 KB |
ans=YES N=200 |
30 |
Correct |
1 ms |
320 KB |
ans=YES N=190 |
31 |
Correct |
1 ms |
324 KB |
ans=YES N=187 |
32 |
Correct |
1 ms |
324 KB |
ans=YES N=187 |
33 |
Correct |
1 ms |
340 KB |
ans=YES N=182 |
34 |
Correct |
1 ms |
340 KB |
ans=YES N=184 |
35 |
Correct |
1 ms |
320 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 |
Correct |
1 ms |
340 KB |
ans=YES N=196 |
40 |
Correct |
1 ms |
340 KB |
ans=YES N=196 |
41 |
Correct |
1 ms |
340 KB |
ans=YES N=196 |
42 |
Correct |
1 ms |
340 KB |
ans=YES N=196 |
43 |
Correct |
1 ms |
340 KB |
ans=YES N=195 |
44 |
Correct |
2 ms |
468 KB |
ans=NO N=1934 |
45 |
Correct |
1 ms |
468 KB |
ans=NO N=1965 |
46 |
Correct |
4 ms |
464 KB |
ans=YES N=1824 |
47 |
Correct |
4 ms |
512 KB |
ans=YES N=1981 |
48 |
Correct |
5 ms |
468 KB |
ans=YES N=1814 |
49 |
Correct |
4 ms |
444 KB |
ans=YES N=1854 |
50 |
Correct |
4 ms |
468 KB |
ans=YES N=1831 |
51 |
Correct |
5 ms |
540 KB |
ans=YES N=2000 |
52 |
Correct |
4 ms |
596 KB |
ans=YES N=1847 |
53 |
Correct |
5 ms |
596 KB |
ans=YES N=1819 |
54 |
Correct |
5 ms |
468 KB |
ans=YES N=1986 |
55 |
Correct |
5 ms |
724 KB |
ans=YES N=2000 |
56 |
Correct |
5 ms |
724 KB |
ans=YES N=1834 |
57 |
Correct |
5 ms |
724 KB |
ans=YES N=1860 |
58 |
Correct |
6 ms |
724 KB |
ans=YES N=1898 |
59 |
Correct |
5 ms |
588 KB |
ans=YES N=1832 |
60 |
Correct |
4 ms |
852 KB |
ans=YES N=1929 |
61 |
Correct |
4 ms |
544 KB |
ans=YES N=1919 |
62 |
Correct |
5 ms |
712 KB |
ans=YES N=1882 |
63 |
Correct |
5 ms |
836 KB |
ans=YES N=1922 |
64 |
Correct |
4 ms |
468 KB |
ans=YES N=1989 |
65 |
Correct |
4 ms |
588 KB |
ans=YES N=1978 |
66 |
Correct |
5 ms |
596 KB |
ans=YES N=1867 |
67 |
Correct |
5 ms |
636 KB |
ans=YES N=1942 |
68 |
Correct |
147 ms |
7456 KB |
ans=NO N=66151 |
69 |
Correct |
35 ms |
4876 KB |
ans=NO N=64333 |
70 |
Correct |
171 ms |
6104 KB |
ans=YES N=69316 |
71 |
Correct |
138 ms |
5876 KB |
ans=YES N=66695 |
72 |
Correct |
147 ms |
6012 KB |
ans=YES N=68436 |
73 |
Correct |
150 ms |
6156 KB |
ans=YES N=70000 |
74 |
Correct |
154 ms |
6312 KB |
ans=YES N=68501 |
75 |
Correct |
150 ms |
6580 KB |
ans=YES N=70000 |
76 |
Correct |
144 ms |
6908 KB |
ans=YES N=65009 |
77 |
Correct |
150 ms |
11264 KB |
ans=YES N=67007 |
78 |
Correct |
192 ms |
13228 KB |
ans=YES N=66357 |
79 |
Correct |
203 ms |
14776 KB |
ans=YES N=65430 |
80 |
Correct |
198 ms |
14108 KB |
ans=YES N=65790 |
81 |
Correct |
163 ms |
13080 KB |
ans=YES N=66020 |
82 |
Correct |
164 ms |
12104 KB |
ans=YES N=65809 |
83 |
Correct |
169 ms |
8076 KB |
ans=YES N=65651 |
84 |
Correct |
215 ms |
18500 KB |
ans=YES N=68040 |
85 |
Correct |
212 ms |
16300 KB |
ans=YES N=66570 |
86 |
Correct |
137 ms |
6364 KB |
ans=YES N=65421 |
87 |
Correct |
162 ms |
7296 KB |
ans=YES N=68351 |
88 |
Correct |
165 ms |
5860 KB |
ans=YES N=67027 |
89 |
Correct |
130 ms |
10308 KB |
ans=YES N=68879 |
90 |
Correct |
148 ms |
7380 KB |
ans=YES N=67256 |
91 |
Correct |
373 ms |
13268 KB |
ans=YES N=148315 |
92 |
Correct |
103 ms |
10616 KB |
ans=NO N=142745 |
93 |
Correct |
107 ms |
12656 KB |
ans=NO N=148443 |
94 |
Correct |
401 ms |
14288 KB |
ans=YES N=148328 |
95 |
Correct |
368 ms |
14448 KB |
ans=YES N=147855 |
96 |
Correct |
392 ms |
14532 KB |
ans=YES N=150000 |
97 |
Correct |
369 ms |
14128 KB |
ans=YES N=144725 |
98 |
Correct |
394 ms |
14388 KB |
ans=YES N=149445 |
99 |
Correct |
372 ms |
14188 KB |
ans=YES N=144455 |
100 |
Correct |
330 ms |
14184 KB |
ans=YES N=143487 |
101 |
Correct |
382 ms |
14740 KB |
ans=YES N=149688 |
102 |
Correct |
395 ms |
26456 KB |
ans=YES N=141481 |
103 |
Correct |
430 ms |
37580 KB |
ans=YES N=147430 |
104 |
Correct |
375 ms |
20932 KB |
ans=YES N=142247 |
105 |
Correct |
384 ms |
25072 KB |
ans=YES N=149941 |
106 |
Correct |
418 ms |
35468 KB |
ans=YES N=141635 |
107 |
Correct |
433 ms |
32012 KB |
ans=YES N=142896 |
108 |
Correct |
404 ms |
35776 KB |
ans=YES N=142069 |
109 |
Correct |
363 ms |
16164 KB |
ans=YES N=142378 |
110 |
Correct |
444 ms |
28752 KB |
ans=YES N=150000 |
111 |
Correct |
433 ms |
41440 KB |
ans=YES N=141452 |
112 |
Correct |
420 ms |
39452 KB |
ans=YES N=134453 |
113 |
Correct |
360 ms |
41432 KB |
ans=YES N=144172 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
134 ms |
7388 KB |
ans=NO N=66151 |
2 |
Correct |
30 ms |
4812 KB |
ans=NO N=64333 |
3 |
Incorrect |
142 ms |
6124 KB |
Contestant's solution is not lexicographically largest at index 69316 (69235 vs 51180) |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
468 KB |
ans=NO N=1934 |
2 |
Correct |
2 ms |
468 KB |
ans=NO N=1965 |
3 |
Incorrect |
4 ms |
468 KB |
Contestant's solution is not lexicographically largest at index 1824 (1813 vs 974) |
4 |
Halted |
0 ms |
0 KB |
- |