//Bismillahirrahmanirrahim
//█▀█─█──█──█▀█─█─█
//█▄█─█──█──█▄█─█▄█
//█─█─█▄─█▄─█─█─█─█
#include <bits/stdc++.h>
using namespace std;
typedef long long lo;
typedef pair< lo,lo > PII;
#define fi first
#define se second
#define mp make_pair
#define endl "\n"
#define pb push_back
#define fio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define FOR for(int i=1;i<=n;i++)
#define mid ((start+end)/2)
#define ort ((bas+son)/2)
const lo inf = 1000000000000000000;
const lo KOK = 100000;
const lo LOG = 30;
const lo li = 200005;
const lo mod = 1000000007;
int n,m,b[li],a[li],k,flag,t,fa[li],vis[li];
int cev;
string s;
map<PII,int> mpp;
vector<int> v[li],vv;
inline int dsu(int x){
if(x==fa[x])return x;
return fa[x]=dsu(fa[x]);
}
inline void dfs(int node){
if(vis[node])return;
vis[node]=1;
vv.pb(node);
for(int i=0;i<(int)v[node].size();i++){
dfs(v[node][i]);
}
}
int main(void){
scanf("%d %d",&n,&t);
FOR fa[i]=i;
FOR{
int x,y;
scanf("%d %d",&x,&y);
if(mpp[{x-1,y}]){
v[mpp[{x-1,y}]].pb(i);
v[i].pb(mpp[{x-1,y}]);
}
if(mpp[{x+1,y}]){
v[mpp[{x+1,y}]].pb(i);
v[i].pb(mpp[{x+1,y}]);
}
if(mpp[{x,y-1}]){
v[mpp[{x,y-1}]].pb(i);
v[i].pb(mpp[{x,y-1}]);
}
if(mpp[{x,y+1}]){
v[mpp[{x,y+1}]].pb(i);
v[i].pb(mpp[{x,y+1}]);
}
if(mpp[{x+1,y+1}]){
v[mpp[{x+1,y+1}]].pb(i);
v[i].pb(mpp[{x+1,y+1}]);
}
if(mpp[{x-1,y+1}]){
v[mpp[{x-1,y+1}]].pb(i);
v[i].pb(mpp[{x-1,y+1}]);
}
if(mpp[{x-1,y-1}]){
v[mpp[{x-1,y-1}]].pb(i);
v[i].pb(mpp[{x-1,y-1}]);
}
if(mpp[{x+1,y-1}]){
v[mpp[{x+1,y-1}]].pb(i);
v[i].pb(mpp[{x+1,y-1}]);
}
mpp[{x,y}]=i;
}
dfs(1);
FOR{
if(vis[i]==0){printf("NO\n");return 0;}
}
printf("YES\n");
for(int i=0;i<n;i++)printf("%d\n",vv[i]);
return 0;
}
Compilation message
skyscrapers.cpp: In function 'int main()':
skyscrapers.cpp:50:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
50 | scanf("%d %d",&n,&t);
| ~~~~~^~~~~~~~~~~~~~~
skyscrapers.cpp:54:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
54 | scanf("%d %d",&x,&y);
| ~~~~~^~~~~~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
4992 KB |
ans=YES N=1 |
2 |
Correct |
4 ms |
4992 KB |
ans=YES N=4 |
3 |
Correct |
4 ms |
4992 KB |
ans=NO N=4 |
4 |
Correct |
4 ms |
4992 KB |
ans=YES N=5 |
5 |
Correct |
5 ms |
4992 KB |
ans=YES N=9 |
6 |
Correct |
5 ms |
4992 KB |
ans=YES N=5 |
7 |
Correct |
4 ms |
4992 KB |
ans=NO N=9 |
8 |
Correct |
4 ms |
5080 KB |
ans=NO N=10 |
9 |
Correct |
4 ms |
4992 KB |
ans=YES N=10 |
10 |
Incorrect |
4 ms |
4992 KB |
Added cell 7 (2,0) not reachable from infinity |
11 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
4992 KB |
ans=YES N=1 |
2 |
Correct |
4 ms |
4992 KB |
ans=YES N=4 |
3 |
Correct |
4 ms |
4992 KB |
ans=NO N=4 |
4 |
Correct |
4 ms |
4992 KB |
ans=YES N=5 |
5 |
Correct |
5 ms |
4992 KB |
ans=YES N=9 |
6 |
Correct |
5 ms |
4992 KB |
ans=YES N=5 |
7 |
Correct |
4 ms |
4992 KB |
ans=NO N=9 |
8 |
Correct |
4 ms |
5080 KB |
ans=NO N=10 |
9 |
Correct |
4 ms |
4992 KB |
ans=YES N=10 |
10 |
Incorrect |
4 ms |
4992 KB |
Added cell 7 (2,0) not reachable from infinity |
11 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
4992 KB |
ans=YES N=1 |
2 |
Correct |
4 ms |
4992 KB |
ans=YES N=4 |
3 |
Correct |
4 ms |
4992 KB |
ans=NO N=4 |
4 |
Correct |
4 ms |
4992 KB |
ans=YES N=5 |
5 |
Correct |
5 ms |
4992 KB |
ans=YES N=9 |
6 |
Correct |
5 ms |
4992 KB |
ans=YES N=5 |
7 |
Correct |
4 ms |
4992 KB |
ans=NO N=9 |
8 |
Correct |
4 ms |
5080 KB |
ans=NO N=10 |
9 |
Correct |
4 ms |
4992 KB |
ans=YES N=10 |
10 |
Incorrect |
4 ms |
4992 KB |
Added cell 7 (2,0) not reachable from infinity |
11 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
9 ms |
6144 KB |
ans=NO N=1934 |
2 |
Correct |
11 ms |
5504 KB |
ans=NO N=1965 |
3 |
Incorrect |
10 ms |
5376 KB |
Added cell 1823 (334,218) not reachable from infinity |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
4992 KB |
ans=YES N=1 |
2 |
Correct |
4 ms |
4992 KB |
ans=YES N=4 |
3 |
Correct |
4 ms |
4992 KB |
ans=NO N=4 |
4 |
Correct |
4 ms |
4992 KB |
ans=YES N=5 |
5 |
Correct |
5 ms |
4992 KB |
ans=YES N=9 |
6 |
Correct |
5 ms |
4992 KB |
ans=YES N=5 |
7 |
Correct |
4 ms |
4992 KB |
ans=NO N=9 |
8 |
Correct |
4 ms |
5080 KB |
ans=NO N=10 |
9 |
Correct |
4 ms |
4992 KB |
ans=YES N=10 |
10 |
Incorrect |
4 ms |
4992 KB |
Added cell 7 (2,0) not reachable from infinity |
11 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
347 ms |
16888 KB |
ans=NO N=66151 |
2 |
Correct |
407 ms |
34924 KB |
ans=NO N=64333 |
3 |
Incorrect |
393 ms |
16164 KB |
Added cell 69316 (-7,-182) not reachable from infinity |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
9 ms |
6144 KB |
ans=NO N=1934 |
2 |
Correct |
11 ms |
5504 KB |
ans=NO N=1965 |
3 |
Incorrect |
10 ms |
5376 KB |
Added cell 1823 (334,218) not reachable from infinity |
4 |
Halted |
0 ms |
0 KB |
- |