Submission #681008

#TimeUsernameProblemLanguageResultExecution timeMemory
681008CutebolWeighting stones (IZhO11_stones)C++17
100 / 100
71 ms7456 KiB
#include <bits/stdc++.h> using namespace std; void fopn(string name){freopen((name+".in").c_str(),"r",stdin); freopen((name+".out").c_str(),"w",stdout);} #define Raiden ios_base::sync_with_stdio(0) ; cin.tie(0) ; cout.tie(0); #define int long long #define itn int #define endl "\n" #define ff first #define ss second const int N = 2e5 + 5 ; const int mod = 1e9 + 7 ; const int inf = 1e9 ; int n ; int lz[4*N] , mn[4*N] , mx[N*4] ; void push( int l , int r , int v ){ if ( lz[v] ){ mn[v] += lz[v] ; mx[v] += lz[v] ; if ( l != r ){ lz[v+v] += lz[v] ; lz[v+v+1] += lz[v] ; } lz[v] = 0 ; } } void upd ( int l , int r , int v , int tl = 1 , int tr = n , int x = 1 ){ // cout << tl << ' ' << tr << ' ' << x << endl ; push( tl , tr , x ) ; if ( tr < l || tl > r ) return ; if ( tr <= r && tl >= l ){ lz[x] += v ; push( tl , tr , x ) ; return ; } int mid = ( tl + tr ) / 2 ; upd( l , r , v , tl , mid , x + x ) ; upd( l , r , v , mid + 1 , tr , x + x + 1 ) ; mn[x] = min ( mn[x+x] , mn[x+x+1] ) ; mx[x] = max ( mx[x+x] , mx[x+x+1] ) ; } void solve(){ cin >> n ; for ( int i = 0 ; i < n ; i ++ ){ int a , b , s = 1 ; cin >> a >> b ; if ( b == 2 ) s = -1 ; upd( 1 , a , s ) ; if ( mn[1] >= 0 && mx[1] > 0 ) cout << ">\n" ; else if ( mn[1] < 0 && mx[1] <= 0 ) cout << "<\n" ; else cout << "?\n" ; } } signed main(){ // fopn("blocks") ; Raiden ; int t = 1 ; // cin >> t ; while ( t -- ) solve() ; }

Compilation message (stderr)

stones.cpp: In function 'void fopn(std::string)':
stones.cpp:5:31: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    5 | void fopn(string name){freopen((name+".in").c_str(),"r",stdin); freopen((name+".out").c_str(),"w",stdout);}
      |                        ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
stones.cpp:5:72: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    5 | void fopn(string name){freopen((name+".in").c_str(),"r",stdin); freopen((name+".out").c_str(),"w",stdout);}
      |                                                                 ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...