제출 #167408

#제출 시각아이디문제언어결과실행 시간메모리
167408GioChkhaidzeSimple game (IZhO17_game)C++14
100 / 100
250 ms11232 KiB
#include <bits/stdc++.h> #define Tree int h,int l,int r #define Left 2*h,l,(l+r)/2 #define Right 2*h+1,(l+r)/2+1,r using namespace std; const int N=1e6+5; int n,m,L,R,type,idx,val,dl,res; int a[N],v[6*N]; void Upd(Tree) { if (r<L || R<l) return ; if (L<=l && r<=R) { v[h]+=dl; return ; } Upd(Left),Upd(Right); } void Get(Tree) { if (idx<l || r<idx) return ; if (l==idx && r==idx) { res+=v[h]; return ; } Get(Left),Get(Right); res+=v[h]; } main () { scanf("%d%d",&n,&m); for (int i=1; i<=n; i++) { scanf("%d",&a[i]); if (i==1) continue; L=min(a[i],a[i-1])+1,R=max(a[i],a[i-1])-1,dl=1; if (L<=R) Upd(1,1,1e6); } while (m--) { scanf("%d",&type); if (type==1) { scanf("%d%d",&idx,&val); if (idx!=1) { L=min(a[idx],a[idx-1])+1; R=max(a[idx],a[idx-1])-1; dl=-1; if (L<=R) Upd(1,1,1e6); } if (idx!=n) { L=min(a[idx],a[idx+1])+1; R=max(a[idx],a[idx+1])-1; dl=-1; if (L<=R) Upd(1,1,1e6); } a[idx]=val; if (idx!=1) { L=min(a[idx],a[idx-1])+1; R=max(a[idx],a[idx-1])-1; dl=1; if (L<=R) Upd(1,1,1e6); } if (idx!=n) { L=min(a[idx],a[idx+1])+1; R=max(a[idx],a[idx+1])-1; dl=1; if (L<=R) Upd(1,1,1e6); } } else { scanf("%d",&idx); res=0; Get(1,1,1e6); printf("%d\n",res); } } }

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

game.cpp:23:7: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main () {
       ^
game.cpp: In function 'int main()':
game.cpp:24:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d",&n,&m);
  ~~~~~^~~~~~~~~~~~~~
game.cpp:27:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d",&a[i]);
   ~~~~~^~~~~~~~~~~~
game.cpp:34:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d",&type);
   ~~~~~^~~~~~~~~~~~
game.cpp:36:9: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    scanf("%d%d",&idx,&val);
    ~~~~~^~~~~~~~~~~~~~~~~~
game.cpp:69:9: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    scanf("%d",&idx);
    ~~~~~^~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...