Submission #554784

#TimeUsernameProblemLanguageResultExecution timeMemory
554784cheetoseSterilizing Spray (JOI15_sterilizing)C++17
100 / 100
173 ms10472 KiB
#include <bits/stdc++.h> #define mp make_pair #define pb push_back #define X first #define Y second #define y0 y12 #define y1 y22 #define INF 987654321987654321 #define PI 3.141592653589793238462643383279502884 #define fup(i,a,b,c) for(int (i)=(a);(i)<=(b);(i)+=(c)) #define fdn(i,a,b,c) for(int (i)=(a);(i)>=(b);(i)-=(c)) #define MEM0(a) memset((a),0,sizeof(a)) #define MEM_1(a) memset((a),-1,sizeof(a)) #define ALL(a) a.begin(),a.end() #define COMPRESS(a) sort(ALL(a));a.resize(unique(ALL(a))-a.begin()) #define SYNC ios_base::sync_with_stdio(false);cin.tie(0) using namespace std; typedef long long ll; typedef long double ld; typedef double db; typedef unsigned int uint; typedef unsigned long long ull; typedef pair<int, int> Pi; typedef pair<ll, ll> Pll; typedef pair<ld, ld> Pd; typedef vector<int> Vi; typedef vector<ll> Vll; typedef vector<ld> Vd; typedef vector<Pi> VPi; typedef vector<Pll> VPll; typedef vector<Pd> VPd; typedef tuple<int, int, int> iii; typedef tuple<int, int, int, int> iiii; typedef tuple<ll, ll, ll> LLL; typedef vector<iii> Viii; typedef vector<LLL> VLLL; typedef complex<double> base; const int MOD = 998244353; ll POW(ll a, ll b, ll MMM = MOD) { ll ret = 1; for (; b; b >>= 1, a = (a*a) % MMM)if (b & 1)ret = (ret*a) % MMM; return ret; } int dx[] = { 0,1,0,-1,1,1,-1,-1 }, dy[] = { 1,0,-1,0,1,-1,1,-1 }; int ddx[] = { -1,-2,1,-2,2,-1,2,1 }, ddy[] = { -2,-1,-2,1,-1,2,1,2 }; ll a[100005],T[100005]; int n,m,k; void upd(int i,ll k){ while(i<=n){ T[i]+=k; i+=(i&-i); } } ll sum(int i){ ll c=0; while(i>0){ c+=T[i]; i-=(i&-i); } return c; } int o[100000],x[100000],y[100000]; int main(){ scanf("%d%d%d",&n,&m,&k); fup(i,1,n,1)scanf("%lld",a+i); fup(i,0,m-1,1)scanf("%d%d%d",o+i,x+i,y+i); set<int> S; fup(i,1,n,1){ if(a[i])S.insert(i); upd(i,a[i]); } fup(i,0,m-1,1){ if(o[i]==1){ if(y[i]>0)S.insert(x[i]); else if(a[x[i]] && !y[i])S.erase(x[i]); ll t=y[i]-a[x[i]]; upd(x[i],t); a[x[i]]=y[i]; }else if(o[i]==2){ if(k==1)continue; auto it=S.lower_bound(x[i]); while(it!=S.end() && *it<=y[i]){ int j=*it; ll nx=a[j]/k; upd(j,nx-a[j]); a[j]=nx; if(!nx)it=S.erase(it); else it++; } }else{ printf("%lld\n",sum(y[i])-sum(x[i]-1)); } } }

Compilation message (stderr)

sterilizing.cpp: In function 'int main()':
sterilizing.cpp:10:30: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
   10 | #define fup(i,a,b,c) for(int (i)=(a);(i)<=(b);(i)+=(c))
      |                              ^
sterilizing.cpp:62:2: note: in expansion of macro 'fup'
   62 |  fup(i,1,n,1)scanf("%lld",a+i);
      |  ^~~
sterilizing.cpp:10:30: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
   10 | #define fup(i,a,b,c) for(int (i)=(a);(i)<=(b);(i)+=(c))
      |                              ^
sterilizing.cpp:63:2: note: in expansion of macro 'fup'
   63 |  fup(i,0,m-1,1)scanf("%d%d%d",o+i,x+i,y+i);
      |  ^~~
sterilizing.cpp:10:30: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
   10 | #define fup(i,a,b,c) for(int (i)=(a);(i)<=(b);(i)+=(c))
      |                              ^
sterilizing.cpp:65:2: note: in expansion of macro 'fup'
   65 |  fup(i,1,n,1){
      |  ^~~
sterilizing.cpp:10:30: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
   10 | #define fup(i,a,b,c) for(int (i)=(a);(i)<=(b);(i)+=(c))
      |                              ^
sterilizing.cpp:69:2: note: in expansion of macro 'fup'
   69 |  fup(i,0,m-1,1){
      |  ^~~
sterilizing.cpp:61:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   61 |  scanf("%d%d%d",&n,&m,&k);
      |  ~~~~~^~~~~~~~~~~~~~~~~~~
sterilizing.cpp:62:19: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   62 |  fup(i,1,n,1)scanf("%lld",a+i);
      |              ~~~~~^~~~~~~~~~~~
sterilizing.cpp:63:21: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   63 |  fup(i,0,m-1,1)scanf("%d%d%d",o+i,x+i,y+i);
      |                ~~~~~^~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...