Submission #90316

#TimeUsernameProblemLanguageResultExecution timeMemory
90316Aydarov03Monkey and Apple-trees (IZhO12_apple)C++14
0 / 100
5 ms504 KiB
#include <bits/stdc++.h> using namespace std; const int N = 1e7 + 7; int tree[N*3]; bool add[N*3]; int c; void push( int tl , int tr , int v ) { if( !add[v] || tree[v] )return; tree[v] = ( tr - tl + 1 ); add[v] = 0; if( tl != tr ) add[v+v] = add[v+v+1] = 1; } void upd( int l , int r , int v = 1 , int tl = 1 , int tr = N ) { push( tl , tr , v ); if( tl > r || tr < l )return; if( l <= tl && tr <= r ) { add[v] = 1; push( tl , tr , v); return; } int mid = ( tl + tr ) / 2; upd( l , r , v + v , tl , mid ); upd( l , r , v+v+1 , mid+1 , tr ); } int get( int l , int r , int v = 1 , int tl = 1 , int tr = N ) { push( tl , tr , v ); if( tl > r || tr < l ) return 0; if( l <= tl && tr <= r ) { if( tree[v] ) return tree[v]; } if(tl == tr && !tree[v] )return 0; int mid = tl + tr >> 1; return get( l , r , v + v , tl , mid ) + get( l , r , v+v+1 , mid+1 , tr ); } main() { int t; scanf("%lld" , &t); while( t-- ) { int d , l , r; scanf("%lld%lld%lld" , &d , &l , &r); l += c , r += c; if( d == 2 ) { upd( l , r ); } else { c = get( l , r ); printf("%lld\n" , c); } } }

Compilation message (stderr)

apple.cpp: In function 'int get(int, int, int, int, int)':
apple.cpp:56:15: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
  int mid = tl + tr >> 1;
            ~~~^~~~
apple.cpp: At global scope:
apple.cpp:62:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main()
      ^
apple.cpp: In function 'int main()':
apple.cpp:65:19: warning: format '%lld' expects argument of type 'long long int*', but argument 2 has type 'int*' [-Wformat=]
  scanf("%lld" , &t);
                 ~~^
apple.cpp:70:38: warning: format '%lld' expects argument of type 'long long int*', but argument 2 has type 'int*' [-Wformat=]
   scanf("%lld%lld%lld" , &d , &l , &r);
                          ~~          ^
apple.cpp:70:38: warning: format '%lld' expects argument of type 'long long int*', but argument 3 has type 'int*' [-Wformat=]
apple.cpp:70:38: warning: format '%lld' expects argument of type 'long long int*', but argument 4 has type 'int*' [-Wformat=]
apple.cpp:81:23: warning: format '%lld' expects argument of type 'long long int', but argument 2 has type 'int' [-Wformat=]
    printf("%lld\n" , c);
                       ^
apple.cpp:65:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%lld" , &t);
  ~~~~~^~~~~~~~~~~~~
apple.cpp:70:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%lld%lld%lld" , &d , &l , &r);
   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...