Submission #90290

#TimeUsernameProblemLanguageResultExecution timeMemory
90290Aydarov03Monkey and Apple-trees (IZhO12_apple)C++14
0 / 100
2 ms256 KiB
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 7; bool tree[N]; int n = N; void push( int tl , int tr , int v ) { if( tree[v] == true ) { tree[v + v] = tree[v + v + 1] = true; tree[v] = false; } } void upd( int l , int r , int v = 1 , int tl = 1 , int tr = 10 ) { if( tl > r || tr < l || tree[v] == true) return; if( l <= tl && tr <= r ) { tree[v] = true; 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 = 10 ) { if( tl > r || tr < l ) return 0; if( l <= tl && tr <= r && tree[v] == true ) { return ( tr - tl + 1); } if( tl == tr )return 0; int mid = ( tl + tr ) / 2; return get( l , r , v+v , tl , mid ) + get( l , r , v+v+1 , mid+1 , tr ); } main() { int t , d , l , r; cin >> t; for(int i = 1; i <= t; i++) { scanf("%d%d%d" , &d , &l , &r); if( d == 2 ) upd( l , r ); else cout << get( l , r ) << endl; } }

Compilation message (stderr)

apple.cpp:54:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main()
      ^
apple.cpp: In function 'int main()':
apple.cpp:61: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...