This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#define fast ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#include <bits/stdc++.h>
using namespace std;
#define sqr 340
#define mp make_pair
#define mid (l+r)/2
#define le node * 2
#define ri node * 2 + 1
#define pb push_back
#define ppb pop_back
#define fi first
#define se second
#define lb lower_bound
#define ub upper_bound
#define ins insert
#define era erase
#define C continue
#define mem(dp,i) memset(dp,i,sizeof(dp))
#define mset multiset
#define all(x) x.begin(), x.end()
#define gc getchar_unlocked
typedef long long ll;
typedef short int si;
typedef long double ld;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pi> vpi;
typedef vector<pll> vpll;
typedef pair<double,ll>pdi;
const ll inf=1e18;
const ll Mod=1e9+7;
const ld Pi=acos(-1) ;
int n , t , yes = 0 , num = 0 ;
vi ans ;
map < pi , int > Node , who , done , crnt ;
map < int , pi > id ;
int X [] = { 0 , 1 , 1 , 1 , 0 , -1 , -1 , -1 } ;
int Y [] = { 1 , 1 , 0 , -1 , -1 , -1 , 0 , 1 } ;
void bfs ( int stx , int sty ) {
done .clear () ;
ans .clear () ;
done [mp(stx,sty)] = 1 ;
set < pi > q ;
q .ins ( { stx , sty } ) ;
while ( q .size () ) {
pi ret = *q .begin () ;
q .era (ret) ;
ans .pb ( who [ret] ) ;
for ( int i = 0 ; i < 8 ; i ++ ) {
int nx = ret.fi + X [i] ;
int ny = ret.se + Y [i] ;
if ( done [mp(nx,ny)] ) C ;
if ( ! Node [mp(nx,ny)] ) C ;
done [mp(nx,ny)] = 1 ;
q .ins ( { nx , ny } ) ;
}
}
if ( ans .size () != n ) cout << "NO" << endl ;
else {
cout << "YES" << endl ;
for ( auto u : ans ) cout << u + 1 << endl ;
}
}
int main () {
cin >> n >> t ;
for ( int i = 0 ; i < n ; i ++ ) {
int x , y ;
cin >> x >> y ;
Node [ mp ( x , y ) ] = 1 ;
who [ mp ( x , y ) ] = i ;
id [i] = mp ( x , y ) ;
}
bfs ( id [0] .fi , id [0] .se ) ;
}
Compilation message (stderr)
skyscrapers.cpp: In function 'void bfs(int, int)':
skyscrapers.cpp:60:27: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
60 | if ( ans .size () != n ) cout << "NO" << endl ;
| ~~~~~~~~~~~~~^~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |