Submission #97666

#TimeUsernameProblemLanguageResultExecution timeMemory
97666KalamSimple game (IZhO17_game)C++11
100 / 100
132 ms6968 KiB
// KALAM # include<bits/stdc++.h> using namespace std; const int N = 1000000 + 77; int n , q; int a[N] , Fen[N]; inline void Add(int x , int y){ for(;x < N;x += x & - x) Fen[x] += y; } inline int Get(int x){ int res = 0; for(;x;x -= x & - x) res += Fen[x]; return res; } int main() { scanf("%d %d" , & n , & q); for(int i = 1;i <= n;++ i) { scanf("%d" , a + i); if(i > 1) Add(max(a[i] , a[i - 1]) , - 1) , Add(min(a[i] , a[i - 1]) , 1); } while(q --){ int tp , x , y; scanf("%d %d" , & tp , & x); if(tp == 2){ printf("%d\n" , Get(x)); continue ; } scanf("%d" , & y); if(x > 1) { Add(max(a[x] , a[x - 1]) , 1) , Add(min(a[x] , a[x - 1]) , - 1); Add(max(y , a[x - 1]) , - 1) , Add(min(y , a[x - 1]) , 1); } if(x < n) { Add(max(a[x] , a[x + 1]) , 1) , Add(min(a[x] , a[x + 1]) , - 1); Add(max(y , a[x + 1]) , - 1) , Add(min(y , a[x + 1]) , 1); } a[x] = y; } return 0; }

Compilation message (stderr)

game.cpp: In function 'int main()':
game.cpp:20:9: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    scanf("%d %d" , & n , & q);
    ~~~~~^~~~~~~~~~~~~~~~~~~~~
game.cpp:22:12: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
       scanf("%d" , a + i);
       ~~~~~^~~~~~~~~~~~~~
game.cpp:28:12: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
       scanf("%d %d" , & tp , & x);
       ~~~~~^~~~~~~~~~~~~~~~~~~~~~
game.cpp:33:12: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
       scanf("%d" , & y);
       ~~~~~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...