#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define F first
#define S second
#define coy cout<<"YES\n"
#define con cout<<"NO\n"
#define co1 cout<<"-1\n"
#define sc(x) scanf("%lld",&x)
#define all(x) x.begin(),x.end()
#define fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;
const int SI=3e5+7;
ll INF=8e18+7;
int dx[] = {1 , -1 , 0 , 0, 1 , 1,-1,-1};
int dy[] = {0 , 0 , 1 , -1, 1 , -1 , 1 ,-1};
int MOD=1e9+7;
ll n,t;
map < pair <ll,ll> ,ll> mp,vis;
pair <ll,ll> p[SI];
vector < ll> ans;
queue < pair < ll,ll> > q;
void BFS()
{
q.push(p[1]);
while (q.size())
{
ll x=q.front().F,y=q.front().S;
q.pop();
pair < ll,ll> XY={x,y};
vis[XY]=1;
ans.pb(mp[XY]);
for (int i=0;i<8;i++)
{
if(vis[{x+dx[i],y+dy[i]}]==0&&mp[{x+dx[i],y+dy[i]}]>0)
q.push({x+dx[i],y+dy[i]}),vis[{x+dx[i],y+dy[i]}]=1;
}
}
}
int main()
{
fast
cin>>n>>t;
for (int i=1;i<=n;i++)
{
ll a,b;
cin>>a>>b;
mp[{a,b}]=i;
p[i]={a,b};
}
BFS();
if (ans.size()!=n)
con;
else
{
coy;
for (auto i:ans)
cout << i<<"\n";
}
// use scanf not cin
return 0;
}
Compilation message
skyscrapers.cpp: In function 'int main()':
skyscrapers.cpp:52:18: warning: comparison of integer expressions of different signedness: 'std::vector<long long int>::size_type' {aka 'long unsigned int'} and 'long long int' [-Wsign-compare]
52 | if (ans.size()!=n)
| ~~~~~~~~~~^~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
ans=YES N=1 |
2 |
Correct |
1 ms |
204 KB |
ans=YES N=4 |
3 |
Correct |
0 ms |
204 KB |
ans=NO N=4 |
4 |
Correct |
1 ms |
204 KB |
ans=YES N=5 |
5 |
Correct |
0 ms |
320 KB |
ans=YES N=9 |
6 |
Correct |
1 ms |
204 KB |
ans=YES N=5 |
7 |
Correct |
1 ms |
316 KB |
ans=NO N=9 |
8 |
Correct |
0 ms |
204 KB |
ans=NO N=10 |
9 |
Correct |
1 ms |
204 KB |
ans=YES N=10 |
10 |
Correct |
1 ms |
204 KB |
ans=YES N=10 |
11 |
Correct |
0 ms |
204 KB |
ans=YES N=10 |
12 |
Correct |
1 ms |
204 KB |
ans=YES N=9 |
13 |
Correct |
1 ms |
324 KB |
ans=YES N=9 |
14 |
Correct |
0 ms |
204 KB |
ans=YES N=8 |
15 |
Correct |
1 ms |
320 KB |
ans=YES N=8 |
16 |
Correct |
1 ms |
204 KB |
ans=NO N=2 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
ans=YES N=1 |
2 |
Correct |
1 ms |
204 KB |
ans=YES N=4 |
3 |
Correct |
0 ms |
204 KB |
ans=NO N=4 |
4 |
Correct |
1 ms |
204 KB |
ans=YES N=5 |
5 |
Correct |
0 ms |
320 KB |
ans=YES N=9 |
6 |
Correct |
1 ms |
204 KB |
ans=YES N=5 |
7 |
Correct |
1 ms |
316 KB |
ans=NO N=9 |
8 |
Correct |
0 ms |
204 KB |
ans=NO N=10 |
9 |
Correct |
1 ms |
204 KB |
ans=YES N=10 |
10 |
Correct |
1 ms |
204 KB |
ans=YES N=10 |
11 |
Correct |
0 ms |
204 KB |
ans=YES N=10 |
12 |
Correct |
1 ms |
204 KB |
ans=YES N=9 |
13 |
Correct |
1 ms |
324 KB |
ans=YES N=9 |
14 |
Correct |
0 ms |
204 KB |
ans=YES N=8 |
15 |
Correct |
1 ms |
320 KB |
ans=YES N=8 |
16 |
Correct |
1 ms |
204 KB |
ans=NO N=2 |
17 |
Correct |
0 ms |
304 KB |
ans=YES N=17 |
18 |
Correct |
1 ms |
312 KB |
ans=YES N=25 |
19 |
Correct |
1 ms |
312 KB |
ans=YES N=100 |
20 |
Correct |
1 ms |
304 KB |
ans=YES N=185 |
21 |
Correct |
1 ms |
332 KB |
ans=NO N=174 |
22 |
Correct |
1 ms |
332 KB |
ans=YES N=90 |
23 |
Correct |
1 ms |
332 KB |
ans=YES N=63 |
24 |
Correct |
1 ms |
312 KB |
ans=YES N=87 |
25 |
Correct |
1 ms |
316 KB |
ans=YES N=183 |
26 |
Correct |
1 ms |
312 KB |
ans=YES N=188 |
27 |
Correct |
1 ms |
332 KB |
ans=YES N=183 |
28 |
Correct |
1 ms |
332 KB |
ans=YES N=189 |
29 |
Correct |
1 ms |
320 KB |
ans=YES N=200 |
30 |
Correct |
1 ms |
332 KB |
ans=YES N=190 |
31 |
Correct |
1 ms |
324 KB |
ans=YES N=187 |
32 |
Correct |
1 ms |
332 KB |
ans=YES N=187 |
33 |
Correct |
1 ms |
332 KB |
ans=YES N=182 |
34 |
Correct |
1 ms |
332 KB |
ans=YES N=184 |
35 |
Correct |
1 ms |
332 KB |
ans=YES N=188 |
36 |
Correct |
1 ms |
324 KB |
ans=YES N=181 |
37 |
Correct |
1 ms |
332 KB |
ans=YES N=188 |
38 |
Correct |
1 ms |
332 KB |
ans=YES N=191 |
39 |
Incorrect |
1 ms |
324 KB |
Added cell 196 (16,2) not reachable from infinity |
40 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
ans=YES N=1 |
2 |
Correct |
1 ms |
204 KB |
ans=YES N=4 |
3 |
Correct |
0 ms |
204 KB |
ans=NO N=4 |
4 |
Correct |
1 ms |
204 KB |
ans=YES N=5 |
5 |
Correct |
0 ms |
320 KB |
ans=YES N=9 |
6 |
Correct |
1 ms |
204 KB |
ans=YES N=5 |
7 |
Correct |
1 ms |
316 KB |
ans=NO N=9 |
8 |
Correct |
0 ms |
204 KB |
ans=NO N=10 |
9 |
Correct |
1 ms |
204 KB |
ans=YES N=10 |
10 |
Correct |
1 ms |
204 KB |
ans=YES N=10 |
11 |
Correct |
0 ms |
204 KB |
ans=YES N=10 |
12 |
Correct |
1 ms |
204 KB |
ans=YES N=9 |
13 |
Correct |
1 ms |
324 KB |
ans=YES N=9 |
14 |
Correct |
0 ms |
204 KB |
ans=YES N=8 |
15 |
Correct |
1 ms |
320 KB |
ans=YES N=8 |
16 |
Correct |
1 ms |
204 KB |
ans=NO N=2 |
17 |
Correct |
0 ms |
304 KB |
ans=YES N=17 |
18 |
Correct |
1 ms |
312 KB |
ans=YES N=25 |
19 |
Correct |
1 ms |
312 KB |
ans=YES N=100 |
20 |
Correct |
1 ms |
304 KB |
ans=YES N=185 |
21 |
Correct |
1 ms |
332 KB |
ans=NO N=174 |
22 |
Correct |
1 ms |
332 KB |
ans=YES N=90 |
23 |
Correct |
1 ms |
332 KB |
ans=YES N=63 |
24 |
Correct |
1 ms |
312 KB |
ans=YES N=87 |
25 |
Correct |
1 ms |
316 KB |
ans=YES N=183 |
26 |
Correct |
1 ms |
312 KB |
ans=YES N=188 |
27 |
Correct |
1 ms |
332 KB |
ans=YES N=183 |
28 |
Correct |
1 ms |
332 KB |
ans=YES N=189 |
29 |
Correct |
1 ms |
320 KB |
ans=YES N=200 |
30 |
Correct |
1 ms |
332 KB |
ans=YES N=190 |
31 |
Correct |
1 ms |
324 KB |
ans=YES N=187 |
32 |
Correct |
1 ms |
332 KB |
ans=YES N=187 |
33 |
Correct |
1 ms |
332 KB |
ans=YES N=182 |
34 |
Correct |
1 ms |
332 KB |
ans=YES N=184 |
35 |
Correct |
1 ms |
332 KB |
ans=YES N=188 |
36 |
Correct |
1 ms |
324 KB |
ans=YES N=181 |
37 |
Correct |
1 ms |
332 KB |
ans=YES N=188 |
38 |
Correct |
1 ms |
332 KB |
ans=YES N=191 |
39 |
Incorrect |
1 ms |
324 KB |
Added cell 196 (16,2) not reachable from infinity |
40 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
460 KB |
ans=NO N=1934 |
2 |
Correct |
2 ms |
452 KB |
ans=NO N=1965 |
3 |
Incorrect |
3 ms |
588 KB |
Contestant's solution is not lexicographically largest at index 1824 (1813 vs 595) |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
ans=YES N=1 |
2 |
Correct |
1 ms |
204 KB |
ans=YES N=4 |
3 |
Correct |
0 ms |
204 KB |
ans=NO N=4 |
4 |
Correct |
1 ms |
204 KB |
ans=YES N=5 |
5 |
Correct |
0 ms |
320 KB |
ans=YES N=9 |
6 |
Correct |
1 ms |
204 KB |
ans=YES N=5 |
7 |
Correct |
1 ms |
316 KB |
ans=NO N=9 |
8 |
Correct |
0 ms |
204 KB |
ans=NO N=10 |
9 |
Correct |
1 ms |
204 KB |
ans=YES N=10 |
10 |
Correct |
1 ms |
204 KB |
ans=YES N=10 |
11 |
Correct |
0 ms |
204 KB |
ans=YES N=10 |
12 |
Correct |
1 ms |
204 KB |
ans=YES N=9 |
13 |
Correct |
1 ms |
324 KB |
ans=YES N=9 |
14 |
Correct |
0 ms |
204 KB |
ans=YES N=8 |
15 |
Correct |
1 ms |
320 KB |
ans=YES N=8 |
16 |
Correct |
1 ms |
204 KB |
ans=NO N=2 |
17 |
Correct |
0 ms |
304 KB |
ans=YES N=17 |
18 |
Correct |
1 ms |
312 KB |
ans=YES N=25 |
19 |
Correct |
1 ms |
312 KB |
ans=YES N=100 |
20 |
Correct |
1 ms |
304 KB |
ans=YES N=185 |
21 |
Correct |
1 ms |
332 KB |
ans=NO N=174 |
22 |
Correct |
1 ms |
332 KB |
ans=YES N=90 |
23 |
Correct |
1 ms |
332 KB |
ans=YES N=63 |
24 |
Correct |
1 ms |
312 KB |
ans=YES N=87 |
25 |
Correct |
1 ms |
316 KB |
ans=YES N=183 |
26 |
Correct |
1 ms |
312 KB |
ans=YES N=188 |
27 |
Correct |
1 ms |
332 KB |
ans=YES N=183 |
28 |
Correct |
1 ms |
332 KB |
ans=YES N=189 |
29 |
Correct |
1 ms |
320 KB |
ans=YES N=200 |
30 |
Correct |
1 ms |
332 KB |
ans=YES N=190 |
31 |
Correct |
1 ms |
324 KB |
ans=YES N=187 |
32 |
Correct |
1 ms |
332 KB |
ans=YES N=187 |
33 |
Correct |
1 ms |
332 KB |
ans=YES N=182 |
34 |
Correct |
1 ms |
332 KB |
ans=YES N=184 |
35 |
Correct |
1 ms |
332 KB |
ans=YES N=188 |
36 |
Correct |
1 ms |
324 KB |
ans=YES N=181 |
37 |
Correct |
1 ms |
332 KB |
ans=YES N=188 |
38 |
Correct |
1 ms |
332 KB |
ans=YES N=191 |
39 |
Incorrect |
1 ms |
324 KB |
Added cell 196 (16,2) not reachable from infinity |
40 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
182 ms |
15808 KB |
ans=NO N=66151 |
2 |
Correct |
33 ms |
5816 KB |
ans=NO N=64333 |
3 |
Incorrect |
136 ms |
11824 KB |
Contestant's solution is not lexicographically largest at index 69316 (69235 vs 13970) |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
460 KB |
ans=NO N=1934 |
2 |
Correct |
2 ms |
452 KB |
ans=NO N=1965 |
3 |
Incorrect |
3 ms |
588 KB |
Contestant's solution is not lexicographically largest at index 1824 (1813 vs 595) |
4 |
Halted |
0 ms |
0 KB |
- |