Submission #232498

# Submission time Handle Problem Language Result Execution time Memory
232498 2020-05-17T08:15:46 Z infinite_iq Ili (COI17_ili) C++14
0 / 100
5 ms 640 KB
#define fast ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#include <bits/stdc++.h>
using namespace std;
#define sqr 270
//#define mp make_pair
#define mid (l+r)/2
#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;
const ll inf=1e18;
const ll mod=1e9+7;
const ld pai=acos(-1);
int n , m ;
string s ;
int l [10009] , r [10009] ;
int on [20009] , ret [20009] , done [20009] ;
int val ( string x ) {
        int ans = 0 ;
        for ( int i = 1 ; i < x.size() ; i ++ ) {
                ans *= 10 ;
                ans += x [i] - '0' - 1 ;
        }
        if ( x [0] == 'c' ) ans += n ;
        return ans ;
}
void dfs ( int node ) {
        if ( done [node] ) return ;
        done [node] = 1 ;
        on   [node] = 0 ;
        if ( node < n ) return ;
        dfs ( l [node] ) ;
        dfs ( r [node] ) ;
}
void check ( int node ) {
        if ( done [node] ) return ;
        done [node] = 1 ;
        ret  [node] = 0 ;
        if ( node < n ) return ;
        check ( l [node] ) ;
        check ( r [node] ) ;
}
int main () {
        fast ;
        mem ( on , -1 ) ;
        mem ( ret, -1 ) ;
        cin >> n >> m >> s ;
        for ( int i = 0 ; i < m ; i ++ ) {
                if ( s [i] == '?' ) C ;
                on [i+n] = ( s [i] == '1' ) ;
        }
        for ( int i = n ; i < n + m ; i ++ ) {
                string A , B ;
                cin >> A >> B ;
                l [i] = val ( A ) ;
                r [i] = val ( B ) ;
        }
        for ( int i = n ; i < n + m ; i ++ ) {
                if ( done [i] || on [i] != 0 ) C ;
                dfs ( i ) ;
        }
        for ( int i = n ; i < n + m ; i ++ ) {
                if ( on [i] != -1 ) C ;
                mem ( done , 0 ) ;
                for ( int j = 0 ; j < n + m ; j ++ ) ret [j] = on [j] ;
                check ( i ) ;
                int z = 1 ;
                for ( int j = n ; j < n + m ; j ++ ) {
                        if ( on [j] == 1 && ret [ l [j] ] == 0 && ret [ r [j] ] == 0 ) z = 0 ;
                        if ( ret[j] == 0 && on [j] == 1 ) z = 0 ;
                }
                if ( !z ) on [i] = 1 ;
        }
        for ( int i = n ; i < n + m ; i ++ ) {
                if ( on [i] == -1 ) cout << '?' ;
                else cout << on [i] ;
        }
        cout << endl ;
}

Compilation message

ili.cpp: In function 'int val(std::__cxx11::string)':
ili.cpp:38:29: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for ( int i = 1 ; i < x.size() ; i ++ ) {
                           ~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 5 ms 640 KB Output is correct
2 Correct 5 ms 640 KB Output is correct
3 Incorrect 5 ms 512 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 640 KB Output is correct
2 Correct 5 ms 640 KB Output is correct
3 Incorrect 5 ms 512 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 640 KB Output is correct
2 Correct 5 ms 640 KB Output is correct
3 Incorrect 5 ms 512 KB Output isn't correct
4 Halted 0 ms 0 KB -