Submission #232781

# Submission time Handle Problem Language Result Execution time Memory
232781 2020-05-18T05:57:06 Z infinite_iq Ili (COI17_ili) C++14
0 / 100
5 ms 512 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 [20009] , r [20009] ;
    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' ;
            }
      		ans -- ;
            if ( x [0] == 'c' ) ans += n ;
            return ans ;
    }
    void dfs ( int node ) {
            if ( done [node] ) return ;
            done [node] = 1 ;
            if ( node < n ) return ;
            dfs ( l [node] ) ;
            dfs ( r [node] ) ;
    }
    int main () {
            fast ;
            mem ( on , -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 = 0 ; i < n + m ; i ++ ) {
                    if ( done [i] ) on [i] = 0 ;
            }
            for ( int i = n ; i < n + m ; i ++ ) {
                    if ( on [i] != -1 ) C ;
                    mem ( done , 0 ) ;
                    dfs ( i ) ;
                    for ( int j = 0 ; j < n + m ; j ++ ) {
                            if ( on [j] == 0 ) done [j] = 1 ;
                            if ( done [j] ) ret [j] = 0 ;
                      		else ret [j] = 1 ; 
                    }
                    for ( int j = n ; j < n + m ; j ++ ) {
                            ret [j] = ( ret [ l[j] ] | ret [ r[j] ] ) ;
                    }
                    int z = 0 ;
                    for ( int j = n ; j < n + m ; j ++ ) {
                            if ( on [j] == -1 ) C ;
                            if ( ret [j] != on [j] ) z = 1 ;
                    }
                    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:33: 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 512 KB Output is correct
2 Correct 5 ms 512 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 512 KB Output is correct
2 Correct 5 ms 512 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 512 KB Output is correct
2 Correct 5 ms 512 KB Output is correct
3 Incorrect 5 ms 512 KB Output isn't correct
4 Halted 0 ms 0 KB -