Submission #279947

#TimeUsernameProblemLanguageResultExecution timeMemory
279947infinite_iqBuilding Skyscrapers (CEOI19_skyscrapers)C++14
8 / 100
3615 ms688352 KiB
#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 ok ( int x , int y ) { if ( done [mp(x,y)] || crnt [mp(x,y)] || yes ) return ; num ++ ; crnt [mp(x,y)] = 1 ; if ( num >= n*n ) { yes = 1 ; return ; } for ( int i = 0 ; i < 8 ; i ++ ) { int nx = x + X [i] ; int ny = y + Y [i] ; ok ( nx , ny ) ; } } int check () { if ( ans .size () != n ) return 0 ; done .clear () ; for ( int i = 0 ; i < n ; i ++ ) { yes = num = 0 ; crnt .clear () ; pi ret = id [i] ; ok ( ret .fi , ret .se ) ; if ( ! yes ) return 0 ; done [ret] = 1 ; } cout << "YES" << endl ; for ( auto u : ans ) { cout << u + 1 << endl ; } exit (0) ; } void bfs ( int stx , int sty ) { done .clear () ; ans .clear () ; done [mp(stx,sty)] = 1 ; queue < pi > q ; q .push ( { stx , sty } ) ; while ( q .size () ) { pi ret = q .front () ; q .pop () ; 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 .push ( { nx , ny } ) ; } } } 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 ) ; } for ( int i = 0 ; i < n ; i ++ ) { bfs ( id [i] .fi , id [i] .se ) ; check () ; } cout << "NO" << endl ; }

Compilation message (stderr)

skyscrapers.cpp: In function 'int check()':
skyscrapers.cpp:56:27: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   56 |         if ( ans .size () != n ) return 0 ;
      |              ~~~~~~~~~~~~~^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...