#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define fi first
#define se second
#define mp make_pair
#define fastIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
int dir[8][2] = {{-1,-1},{-1,0},{-1,+1},{0,-1},{0,+1},{+1,-1},{+1,0},{+1,+1}};
map<pii,int> indx;
map<pii,int> active;
set<pii> nt;
vector<pii> fin;
void dfs(pii chk){
active[chk]=true;
fin.push_back(chk);
pii nx;
for(int dv = 0; dv < 8; dv ++ ){
nx = mp(chk.fi + dir[dv][0], chk.se + dir[dv][1]);
if(nt.count(nx)){
nt.erase(nx);
dfs(nx);
}
}
}
int main(){
fastIO;
int n;
cin >> n;
int ty;
cin >> ty;
int ii, jj;
vector<pii> ord;
for(int i = 1; i <= n; i ++) {
cin >> ii >> jj;
ord.push_back(mp(ii,jj));
indx[mp(ii,jj)]=i;
}
sort(ord.begin(), ord.end());
fin.push_back(ord[0]);
active[ord[0]]=true;
bool go;
pii nx;
for(int i = 1; i < ord.size(); i ++ ){
go = false;
for(int v = 0; v < 8; v ++ ){
nx = mp(ord[i].fi+dir[v][0],ord[i].se+dir[v][1]);
if(active[nx]) go = true;
}
if(go){
dfs(ord[i]);
}
else{
nt.insert(ord[i]);
}
}
if(!nt.empty()){
cout << "NO\n";
}
else{
cout << "YES\n";
for(auto x : fin){
cout << indx[x] << " ";
}
}
return 0;
}
Compilation message
skyscrapers.cpp: In function 'int main()':
skyscrapers.cpp:52:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
52 | for(int i = 1; i < ord.size(); i ++ ){
| ~~^~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
ans=YES N=1 |
2 |
Correct |
1 ms |
364 KB |
ans=YES N=4 |
3 |
Correct |
1 ms |
364 KB |
ans=NO N=4 |
4 |
Correct |
1 ms |
364 KB |
ans=YES N=5 |
5 |
Correct |
1 ms |
364 KB |
ans=YES N=9 |
6 |
Correct |
1 ms |
364 KB |
ans=YES N=5 |
7 |
Correct |
1 ms |
364 KB |
ans=NO N=9 |
8 |
Correct |
1 ms |
364 KB |
ans=NO N=10 |
9 |
Correct |
1 ms |
364 KB |
ans=YES N=10 |
10 |
Correct |
0 ms |
364 KB |
ans=YES N=10 |
11 |
Correct |
1 ms |
364 KB |
ans=YES N=10 |
12 |
Correct |
1 ms |
364 KB |
ans=YES N=9 |
13 |
Correct |
1 ms |
364 KB |
ans=YES N=9 |
14 |
Correct |
1 ms |
364 KB |
ans=YES N=8 |
15 |
Correct |
1 ms |
364 KB |
ans=YES N=8 |
16 |
Correct |
1 ms |
364 KB |
ans=NO N=2 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
ans=YES N=1 |
2 |
Correct |
1 ms |
364 KB |
ans=YES N=4 |
3 |
Correct |
1 ms |
364 KB |
ans=NO N=4 |
4 |
Correct |
1 ms |
364 KB |
ans=YES N=5 |
5 |
Correct |
1 ms |
364 KB |
ans=YES N=9 |
6 |
Correct |
1 ms |
364 KB |
ans=YES N=5 |
7 |
Correct |
1 ms |
364 KB |
ans=NO N=9 |
8 |
Correct |
1 ms |
364 KB |
ans=NO N=10 |
9 |
Correct |
1 ms |
364 KB |
ans=YES N=10 |
10 |
Correct |
0 ms |
364 KB |
ans=YES N=10 |
11 |
Correct |
1 ms |
364 KB |
ans=YES N=10 |
12 |
Correct |
1 ms |
364 KB |
ans=YES N=9 |
13 |
Correct |
1 ms |
364 KB |
ans=YES N=9 |
14 |
Correct |
1 ms |
364 KB |
ans=YES N=8 |
15 |
Correct |
1 ms |
364 KB |
ans=YES N=8 |
16 |
Correct |
1 ms |
364 KB |
ans=NO N=2 |
17 |
Correct |
1 ms |
364 KB |
ans=YES N=17 |
18 |
Correct |
1 ms |
364 KB |
ans=YES N=25 |
19 |
Correct |
1 ms |
364 KB |
ans=YES N=100 |
20 |
Correct |
1 ms |
364 KB |
ans=YES N=185 |
21 |
Correct |
1 ms |
492 KB |
ans=NO N=174 |
22 |
Correct |
1 ms |
364 KB |
ans=YES N=90 |
23 |
Correct |
1 ms |
364 KB |
ans=YES N=63 |
24 |
Correct |
1 ms |
364 KB |
ans=YES N=87 |
25 |
Correct |
1 ms |
364 KB |
ans=YES N=183 |
26 |
Correct |
1 ms |
364 KB |
ans=YES N=188 |
27 |
Correct |
1 ms |
364 KB |
ans=YES N=183 |
28 |
Correct |
1 ms |
364 KB |
ans=YES N=189 |
29 |
Correct |
1 ms |
364 KB |
ans=YES N=200 |
30 |
Correct |
1 ms |
364 KB |
ans=YES N=190 |
31 |
Correct |
1 ms |
364 KB |
ans=YES N=187 |
32 |
Correct |
1 ms |
364 KB |
ans=YES N=187 |
33 |
Correct |
1 ms |
364 KB |
ans=YES N=182 |
34 |
Correct |
1 ms |
364 KB |
ans=YES N=184 |
35 |
Correct |
1 ms |
364 KB |
ans=YES N=188 |
36 |
Correct |
1 ms |
364 KB |
ans=YES N=181 |
37 |
Incorrect |
1 ms |
384 KB |
Added cell 151 (-866175210,267653114) not reachable from infinity |
38 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
ans=YES N=1 |
2 |
Correct |
1 ms |
364 KB |
ans=YES N=4 |
3 |
Correct |
1 ms |
364 KB |
ans=NO N=4 |
4 |
Correct |
1 ms |
364 KB |
ans=YES N=5 |
5 |
Correct |
1 ms |
364 KB |
ans=YES N=9 |
6 |
Correct |
1 ms |
364 KB |
ans=YES N=5 |
7 |
Correct |
1 ms |
364 KB |
ans=NO N=9 |
8 |
Correct |
1 ms |
364 KB |
ans=NO N=10 |
9 |
Correct |
1 ms |
364 KB |
ans=YES N=10 |
10 |
Correct |
0 ms |
364 KB |
ans=YES N=10 |
11 |
Correct |
1 ms |
364 KB |
ans=YES N=10 |
12 |
Correct |
1 ms |
364 KB |
ans=YES N=9 |
13 |
Correct |
1 ms |
364 KB |
ans=YES N=9 |
14 |
Correct |
1 ms |
364 KB |
ans=YES N=8 |
15 |
Correct |
1 ms |
364 KB |
ans=YES N=8 |
16 |
Correct |
1 ms |
364 KB |
ans=NO N=2 |
17 |
Correct |
1 ms |
364 KB |
ans=YES N=17 |
18 |
Correct |
1 ms |
364 KB |
ans=YES N=25 |
19 |
Correct |
1 ms |
364 KB |
ans=YES N=100 |
20 |
Correct |
1 ms |
364 KB |
ans=YES N=185 |
21 |
Correct |
1 ms |
492 KB |
ans=NO N=174 |
22 |
Correct |
1 ms |
364 KB |
ans=YES N=90 |
23 |
Correct |
1 ms |
364 KB |
ans=YES N=63 |
24 |
Correct |
1 ms |
364 KB |
ans=YES N=87 |
25 |
Correct |
1 ms |
364 KB |
ans=YES N=183 |
26 |
Correct |
1 ms |
364 KB |
ans=YES N=188 |
27 |
Correct |
1 ms |
364 KB |
ans=YES N=183 |
28 |
Correct |
1 ms |
364 KB |
ans=YES N=189 |
29 |
Correct |
1 ms |
364 KB |
ans=YES N=200 |
30 |
Correct |
1 ms |
364 KB |
ans=YES N=190 |
31 |
Correct |
1 ms |
364 KB |
ans=YES N=187 |
32 |
Correct |
1 ms |
364 KB |
ans=YES N=187 |
33 |
Correct |
1 ms |
364 KB |
ans=YES N=182 |
34 |
Correct |
1 ms |
364 KB |
ans=YES N=184 |
35 |
Correct |
1 ms |
364 KB |
ans=YES N=188 |
36 |
Correct |
1 ms |
364 KB |
ans=YES N=181 |
37 |
Incorrect |
1 ms |
384 KB |
Added cell 151 (-866175210,267653114) not reachable from infinity |
38 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
1516 KB |
ans=NO N=1934 |
2 |
Correct |
4 ms |
876 KB |
ans=NO N=1965 |
3 |
Incorrect |
3 ms |
620 KB |
Contestant's solution is not lexicographically largest at index 1824 (1813 vs 1702) |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
ans=YES N=1 |
2 |
Correct |
1 ms |
364 KB |
ans=YES N=4 |
3 |
Correct |
1 ms |
364 KB |
ans=NO N=4 |
4 |
Correct |
1 ms |
364 KB |
ans=YES N=5 |
5 |
Correct |
1 ms |
364 KB |
ans=YES N=9 |
6 |
Correct |
1 ms |
364 KB |
ans=YES N=5 |
7 |
Correct |
1 ms |
364 KB |
ans=NO N=9 |
8 |
Correct |
1 ms |
364 KB |
ans=NO N=10 |
9 |
Correct |
1 ms |
364 KB |
ans=YES N=10 |
10 |
Correct |
0 ms |
364 KB |
ans=YES N=10 |
11 |
Correct |
1 ms |
364 KB |
ans=YES N=10 |
12 |
Correct |
1 ms |
364 KB |
ans=YES N=9 |
13 |
Correct |
1 ms |
364 KB |
ans=YES N=9 |
14 |
Correct |
1 ms |
364 KB |
ans=YES N=8 |
15 |
Correct |
1 ms |
364 KB |
ans=YES N=8 |
16 |
Correct |
1 ms |
364 KB |
ans=NO N=2 |
17 |
Correct |
1 ms |
364 KB |
ans=YES N=17 |
18 |
Correct |
1 ms |
364 KB |
ans=YES N=25 |
19 |
Correct |
1 ms |
364 KB |
ans=YES N=100 |
20 |
Correct |
1 ms |
364 KB |
ans=YES N=185 |
21 |
Correct |
1 ms |
492 KB |
ans=NO N=174 |
22 |
Correct |
1 ms |
364 KB |
ans=YES N=90 |
23 |
Correct |
1 ms |
364 KB |
ans=YES N=63 |
24 |
Correct |
1 ms |
364 KB |
ans=YES N=87 |
25 |
Correct |
1 ms |
364 KB |
ans=YES N=183 |
26 |
Correct |
1 ms |
364 KB |
ans=YES N=188 |
27 |
Correct |
1 ms |
364 KB |
ans=YES N=183 |
28 |
Correct |
1 ms |
364 KB |
ans=YES N=189 |
29 |
Correct |
1 ms |
364 KB |
ans=YES N=200 |
30 |
Correct |
1 ms |
364 KB |
ans=YES N=190 |
31 |
Correct |
1 ms |
364 KB |
ans=YES N=187 |
32 |
Correct |
1 ms |
364 KB |
ans=YES N=187 |
33 |
Correct |
1 ms |
364 KB |
ans=YES N=182 |
34 |
Correct |
1 ms |
364 KB |
ans=YES N=184 |
35 |
Correct |
1 ms |
364 KB |
ans=YES N=188 |
36 |
Correct |
1 ms |
364 KB |
ans=YES N=181 |
37 |
Incorrect |
1 ms |
384 KB |
Added cell 151 (-866175210,267653114) not reachable from infinity |
38 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
120 ms |
13152 KB |
ans=NO N=66151 |
2 |
Correct |
188 ms |
34532 KB |
ans=NO N=64333 |
3 |
Incorrect |
130 ms |
11488 KB |
Contestant's solution is not lexicographically largest at index 69316 (69235 vs 7320) |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
1516 KB |
ans=NO N=1934 |
2 |
Correct |
4 ms |
876 KB |
ans=NO N=1965 |
3 |
Incorrect |
3 ms |
620 KB |
Contestant's solution is not lexicographically largest at index 1824 (1813 vs 1702) |
4 |
Halted |
0 ms |
0 KB |
- |