제출 #90319

#제출 시각아이디문제언어결과실행 시간메모리
90319Aydarov03원숭이와 사과 나무 (IZhO12_apple)C++14
0 / 100
470 ms156156 KiB
#include <stdio.h> using namespace std; const int N = 1e7 + 7; int tree[N*5]; bool add[N*5]; 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("%d" , &t); while( t-- ) { int d , l , r; scanf("%d%d%d" , &d , &l , &r); l += c , r += c; if( d == 2 ) { upd( l , r ); } else { c = get( l , r ); printf("%d\n" , c); } } }

컴파일 시 표준 에러 (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:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d" , &t);
  ~~~~~^~~~~~~~~~~
apple.cpp:70:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d%d%d" , &d , &l , &r);
   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...