제출 #90301

#제출 시각아이디문제언어결과실행 시간메모리
90301Aydarov03원숭이와 사과 나무 (IZhO12_apple)C++14
0 / 100
604 ms247056 KiB
#include <stdio.h> #define int long long using namespace std; const int N = 1e7 + 7; int tree[N*4]; bool add[N*4]; 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); } } }

컴파일 시 표준 에러 (stderr) 메시지

apple.cpp: In function 'long long int get(long long int, long long int, long long int, long long int, long long int)':
apple.cpp:57:15: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
  int mid = tl + tr >> 1;
            ~~~^~~~
apple.cpp: At global scope:
apple.cpp:63:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main()
      ^
apple.cpp: In function 'int main()':
apple.cpp:66:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%lld" , &t);
  ~~~~~^~~~~~~~~~~~~
apple.cpp:71: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...