Submission #233458

#TimeUsernameProblemLanguageResultExecution timeMemory
233458DodgeBallManSimple game (IZhO17_game)C++14
100 / 100
101 ms6952 KiB
#include <bits/stdc++.h> using namespace std; const int N = 1e6 + 10; int n, m, t[N], a[N]; void up( int idx, int va ) { for( int i = idx ; i < N ; i += i & -i ) t[i] += va; } int query( int idx ) { int ret = 0; for( int i = idx ; i > 0 ; i -= i & -i ) ret += t[i]; return ret; } int main() { scanf("%d %d",&n,&m); for( int i = 1 ; i <= n ; i++ ) scanf("%d",&a[i]); for( int i = 1 ; i <= n ; i++ ) if( i < n ) up( min( a[i], a[i+1] ), 1 ), up( max( a[i], a[i+1] ), -1 ); while( m-- ) { int t, i, h; scanf("%d %d",&t,&i); if( t == 1 ) { scanf("%d",&h); if( i > 1 ) up( min( a[i-1], a[i] ), -1 ), up( max( a[i-1], a[i] ), 1 ); if( i < n ) up( min( a[i], a[i+1] ), -1 ), up( max( a[i], a[i+1] ), 1 ); a[i] = h; if( i > 1 ) up( min( a[i-1], a[i] ), 1 ), up( max( a[i-1], a[i] ), -1 ); if( i < n ) up( min( a[i], a[i+1] ), 1 ), up( max( a[i], a[i+1] ), -1 ); } else printf("%d\n",query(i)); } return 0; }

Compilation message (stderr)

game.cpp: In function 'int main()':
game.cpp:16:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d %d",&n,&m);
     ~~~~~^~~~~~~~~~~~~~~
game.cpp:17:42: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     for( int i = 1 ; i <= n ; i++ ) scanf("%d",&a[i]);
                                     ~~~~~^~~~~~~~~~~~
game.cpp:21:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d %d",&t,&i);
         ~~~~~^~~~~~~~~~~~~~~
game.cpp:23:18: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
             scanf("%d",&h);
             ~~~~~^~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...