Submission #593307

#TimeUsernameProblemLanguageResultExecution timeMemory
593307LucaGregSimple game (IZhO17_game)C++14
0 / 100
355 ms4300 KiB
#include <bits/stdc++.h> using namespace std; int sp[1000010]; int h[100010]; int main() { int n, m; scanf("%d %d", &n, &m); scanf("%d", &h[1]); for(int i=2;i<=n;i++){ scanf("%d", &h[i]); sp[min(h[i-1], h[i])]++; sp[max(h[i-1], h[i])+1]--; } for(int i=1;i<1000010;i++){ sp[i] += sp[i-1]; } for(int i=0;i<m;i++){ int t; scanf("%d", &t); if(t==2){ int hq; scanf("%d", &hq); printf("%d\n", sp[hq]); }else if(t==1){ int pos, val; scanf("%d %d", &pos, &val); if(pos==1){ for(int j=min(h[pos], h[pos+1]);j<=max(h[pos], h[pos+1]);j++){ sp[j]--; } for(int j=min(val, h[pos+1]);j<=max(val, h[pos+1]);j++){ sp[j]++; } }else if(pos==n){ for(int j=min(h[pos], h[pos-1]);j<=max(h[pos], h[pos-1]);j++){ sp[j]--; } for(int j=min(val, h[pos-1]);j<=max(val, h[pos-1]);j++){ sp[j]++; } }else{ for(int j=min(h[pos], h[pos+1]);j<=max(h[pos], h[pos+1]);j++){ sp[j]--; } for(int j=min(h[pos], h[pos-1]);j<=max(h[pos], h[pos-1]);j++){ sp[j]--; } for(int j=min(val, h[pos+1]);j<=max(val, h[pos+1]);j++){ sp[j]++; } for(int j=min(val, h[pos-1]);j<=max(val, h[pos-1]);j++){ sp[j]++; } } } } return 0; }

Compilation message (stderr)

game.cpp: In function 'int main()':
game.cpp:11:20: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   11 |     int n, m; scanf("%d %d", &n, &m);
      |               ~~~~~^~~~~~~~~~~~~~~~~
game.cpp:12:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   12 |     scanf("%d", &h[1]);
      |     ~~~~~^~~~~~~~~~~~~
game.cpp:14:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   14 |         scanf("%d", &h[i]);
      |         ~~~~~^~~~~~~~~~~~~
game.cpp:22:21: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   22 |         int t; scanf("%d", &t);
      |                ~~~~~^~~~~~~~~~
game.cpp:24:26: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   24 |             int hq; scanf("%d", &hq);
      |                     ~~~~~^~~~~~~~~~~
game.cpp:27:32: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   27 |             int pos, val; scanf("%d %d", &pos, &val);
      |                           ~~~~~^~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...