Submission #279957

# Submission time Handle Problem Language Result Execution time Memory
279957 2020-08-22T12:21:50 Z infinite_iq Building Skyscrapers (CEOI19_skyscrapers) C++14
8 / 100
3500 ms 346348 KB
#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/4)*(n/4)*4 ) {
                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

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 time Memory Grader output
1 Correct 0 ms 256 KB ans=YES N=1
2 Correct 1 ms 256 KB ans=YES N=4
3 Correct 0 ms 256 KB ans=NO N=4
4 Correct 0 ms 256 KB ans=YES N=5
5 Correct 1 ms 384 KB ans=YES N=9
6 Correct 0 ms 256 KB ans=YES N=5
7 Correct 1 ms 384 KB ans=NO N=9
8 Correct 1 ms 256 KB ans=NO N=10
9 Correct 1 ms 384 KB ans=YES N=10
10 Correct 1 ms 384 KB ans=YES N=10
11 Correct 1 ms 256 KB ans=YES N=10
12 Correct 1 ms 384 KB ans=YES N=9
13 Correct 1 ms 384 KB ans=YES N=9
14 Correct 1 ms 360 KB ans=YES N=8
15 Correct 1 ms 384 KB ans=YES N=8
16 Correct 0 ms 256 KB ans=NO N=2
# Verdict Execution time Memory Grader output
1 Correct 0 ms 256 KB ans=YES N=1
2 Correct 1 ms 256 KB ans=YES N=4
3 Correct 0 ms 256 KB ans=NO N=4
4 Correct 0 ms 256 KB ans=YES N=5
5 Correct 1 ms 384 KB ans=YES N=9
6 Correct 0 ms 256 KB ans=YES N=5
7 Correct 1 ms 384 KB ans=NO N=9
8 Correct 1 ms 256 KB ans=NO N=10
9 Correct 1 ms 384 KB ans=YES N=10
10 Correct 1 ms 384 KB ans=YES N=10
11 Correct 1 ms 256 KB ans=YES N=10
12 Correct 1 ms 384 KB ans=YES N=9
13 Correct 1 ms 384 KB ans=YES N=9
14 Correct 1 ms 360 KB ans=YES N=8
15 Correct 1 ms 384 KB ans=YES N=8
16 Correct 0 ms 256 KB ans=NO N=2
17 Correct 2 ms 384 KB ans=YES N=17
18 Correct 5 ms 384 KB ans=YES N=25
19 Execution timed out 3556 ms 3320 KB Time limit exceeded
20 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 256 KB ans=YES N=1
2 Correct 1 ms 256 KB ans=YES N=4
3 Correct 0 ms 256 KB ans=NO N=4
4 Correct 0 ms 256 KB ans=YES N=5
5 Correct 1 ms 384 KB ans=YES N=9
6 Correct 0 ms 256 KB ans=YES N=5
7 Correct 1 ms 384 KB ans=NO N=9
8 Correct 1 ms 256 KB ans=NO N=10
9 Correct 1 ms 384 KB ans=YES N=10
10 Correct 1 ms 384 KB ans=YES N=10
11 Correct 1 ms 256 KB ans=YES N=10
12 Correct 1 ms 384 KB ans=YES N=9
13 Correct 1 ms 384 KB ans=YES N=9
14 Correct 1 ms 360 KB ans=YES N=8
15 Correct 1 ms 384 KB ans=YES N=8
16 Correct 0 ms 256 KB ans=NO N=2
17 Correct 2 ms 384 KB ans=YES N=17
18 Correct 5 ms 384 KB ans=YES N=25
19 Execution timed out 3556 ms 3320 KB Time limit exceeded
20 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 14 ms 1664 KB ans=NO N=1934
2 Correct 206 ms 964 KB ans=NO N=1965
3 Execution timed out 3564 ms 346348 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 256 KB ans=YES N=1
2 Correct 1 ms 256 KB ans=YES N=4
3 Correct 0 ms 256 KB ans=NO N=4
4 Correct 0 ms 256 KB ans=YES N=5
5 Correct 1 ms 384 KB ans=YES N=9
6 Correct 0 ms 256 KB ans=YES N=5
7 Correct 1 ms 384 KB ans=NO N=9
8 Correct 1 ms 256 KB ans=NO N=10
9 Correct 1 ms 384 KB ans=YES N=10
10 Correct 1 ms 384 KB ans=YES N=10
11 Correct 1 ms 256 KB ans=YES N=10
12 Correct 1 ms 384 KB ans=YES N=9
13 Correct 1 ms 384 KB ans=YES N=9
14 Correct 1 ms 360 KB ans=YES N=8
15 Correct 1 ms 384 KB ans=YES N=8
16 Correct 0 ms 256 KB ans=NO N=2
17 Correct 2 ms 384 KB ans=YES N=17
18 Correct 5 ms 384 KB ans=YES N=25
19 Execution timed out 3556 ms 3320 KB Time limit exceeded
20 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3553 ms 22120 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 14 ms 1664 KB ans=NO N=1934
2 Correct 206 ms 964 KB ans=NO N=1965
3 Execution timed out 3564 ms 346348 KB Time limit exceeded
4 Halted 0 ms 0 KB -