제출 #567651

#제출 시각아이디문제언어결과실행 시간메모리
567651robsSimple game (IZhO17_game)C++17
0 / 100
4 ms3728 KiB
#include <bits/stdc++.h> using namespace std; const int maxn = 5e5; int BIT[maxn], v[maxn]; void update(int id, int val) { while(id < maxn) { BIT[id] += val; id += id&-id; } } int query(int id) { int aux = 0; while(id > 0) { aux += BIT[id]; id -= id&-id; } return aux; } int main(){ int n, m; scanf("%d %d",&n,&m); for(int i = 1; i <= n; i++) scanf("%d",&v[i]); for(int i = 1; i < n; i++) { update(min(v[i], v[i+1]), 1); update(max(v[i], v[i+1])+1, -1); } for(int i = 1; i <= m; i++) { int tp; scanf("%d",&tp); if(tp == 1) { int id, val; scanf("%d %d",&id,&val); update(min(v[id], v[id+1]), -1); update(max(v[id], v[id+1])+1, 1); v[id] = val; update(min(v[id], v[id+1]), 1); update(max(v[id], v[id+1])+1, -1); } if(tp == 2) { int val; scanf("%d",&val); int resp = query(val); printf("%d\n",resp); } } }

컴파일 시 표준 에러 (stderr) 메시지

game.cpp: In function 'int main()':
game.cpp:29:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   29 |   scanf("%d %d",&n,&m);
      |   ~~~~~^~~~~~~~~~~~~~~
game.cpp:32:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   32 |     scanf("%d",&v[i]);
      |     ~~~~~^~~~~~~~~~~~
game.cpp:43:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   43 |     scanf("%d",&tp);
      |     ~~~~~^~~~~~~~~~
game.cpp:48:12: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   48 |       scanf("%d %d",&id,&val);
      |       ~~~~~^~~~~~~~~~~~~~~~~~
game.cpp:61:12: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   61 |       scanf("%d",&val);
      |       ~~~~~^~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...