Submission #87151

#TimeUsernameProblemLanguageResultExecution timeMemory
87151rzbtSimple game (IZhO17_game)C++14
100 / 100
127 ms22768 KiB
#include <bits/stdc++.h> #define mp make_pair #define pb push_back #define F first #define S second #define all(x) x.begin(),x.end() #define MAXN 100005 #define MAXF 1000006 typedef long long ll; using namespace std; int bit[MAXF]; int niz[MAXN]; void dodaj(int p,int x){ for(;p<MAXF;p+=(-p)&p) bit[p]+=x; } int dobij(int p){ int zbir=0; for(;p>0;p-=(-p)&p) zbir+=bit[p]; return zbir; } void range(int a,int b,int x){ dodaj(a,x); dodaj(b+1,-x); } int n,m; int main() { scanf("%d %d", &n, &m); scanf("%d",niz+1); for(int i=2;i<=n;i++){ scanf("%d",niz+i); range(min(niz[i],niz[i-1]),max(niz[i],niz[i-1]),1); } for(int i=1;i<=m;i++){ int q; scanf("%d", &q); if(q==1){ int t1,t2; scanf("%d %d", &t1, &t2); if(t1!=1)range(min(niz[t1],niz[t1-1]),max(niz[t1],niz[t1-1]),-1); if(t1!=n)range(min(niz[t1],niz[t1+1]),max(niz[t1],niz[t1+1]),-1); niz[t1]=t2; if(t1!=1)range(min(niz[t1],niz[t1-1]),max(niz[t1],niz[t1-1]),1); if(t1!=n)range(min(niz[t1],niz[t1+1]),max(niz[t1],niz[t1+1]),1); }else{ int t; scanf("%d", &t); printf("%d\n",dobij(t)); } } return 0; }

Compilation message (stderr)

game.cpp: In function 'int main()':
game.cpp:38: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:39:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d",niz+1);
     ~~~~~^~~~~~~~~~~~
game.cpp:41:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d",niz+i);
         ~~~~~^~~~~~~~~~~~
game.cpp:46:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d", &q);
         ~~~~~^~~~~~~~~~
game.cpp:49:18: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
             scanf("%d %d", &t1, &t2);
             ~~~~~^~~~~~~~~~~~~~~~~~~
game.cpp:57:18: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
             scanf("%d", &t);
             ~~~~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...