답안 #264862

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
264862 2020-08-14T10:38:29 Z Goolakh Sterilizing Spray (JOI15_sterilizing) C++17
100 / 100
298 ms 5384 KB
// FUCKED UP FUCKED UP FUCKED UP FUCKED UP FUCKED UP
#include <bits/stdc++.h>
using namespace std;

#pragma GCC optimize("O2")

#define F first
#define S second
#define pb push_back
#define SZ(x) (ll)(x.size())
#define all(x) x.begin(),x.end()
#define MP make_pair

typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;

//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const ll maxn=1e5+10, maxm=1e6+10, lg=10, mod=1e9+7, inf=1e18;

#define lc (v<<1)
#define rc (lc^1)
#define md ((s+t)>>1)

ll n,q,k,sum[maxn<<2];
void spray(ll l,ll r,ll s=0,ll t=n,ll v=1){
	if(l>=t || r<=s || sum[v]==0) return;
	if(t-s==1) return void(sum[v]/=k);
	spray(l,r,s,md,lc), spray(l,r,md,t,rc);
	sum[v]=sum[lc]+sum[rc];
}
void goz(ll i,ll x,ll s=0,ll t=n,ll v=1){
	if(t-s==1) return void(sum[v]=x);
	(i<md ? goz(i,x,s,md,lc):goz(i,x,md,t,rc));
	sum[v]=sum[lc]+sum[rc];
}
ll get(ll l,ll r,ll s=0,ll t=n,ll v=1){
	if(l>=t || r<=s) return 0;
	if(l<=s && r>=t) return sum[v];
	return get(l,r,s,md,lc)+get(l,r,md,t,rc);
}


int main(){
	ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	
	cin>>n>>q>>k;
	for(int i=0,x;i<n;i++) cin>>x, goz(i,x);
	while(q--){
		ll ty,l,r; cin>>ty>>l>>r;
		if(ty==1) goz(--l,r);
		if(ty==2 && k>=2) spray(--l,r);
		if(ty==3) cout<<get(--l,r)<<'\n';
	}
	
	return 0;
}
// a denial a denial a denial a denial a denial a denial
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 4 ms 512 KB Output is correct
6 Correct 4 ms 512 KB Output is correct
7 Correct 4 ms 512 KB Output is correct
8 Correct 4 ms 512 KB Output is correct
9 Correct 5 ms 512 KB Output is correct
10 Correct 4 ms 640 KB Output is correct
11 Correct 4 ms 512 KB Output is correct
12 Correct 4 ms 512 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 62 ms 3704 KB Output is correct
2 Correct 51 ms 3448 KB Output is correct
3 Correct 50 ms 4372 KB Output is correct
4 Correct 63 ms 4856 KB Output is correct
5 Correct 75 ms 5368 KB Output is correct
6 Correct 76 ms 5368 KB Output is correct
7 Correct 78 ms 5384 KB Output is correct
8 Correct 76 ms 5368 KB Output is correct
9 Correct 74 ms 5240 KB Output is correct
10 Correct 82 ms 5240 KB Output is correct
11 Correct 90 ms 5288 KB Output is correct
12 Correct 77 ms 5228 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 20 ms 920 KB Output is correct
2 Correct 18 ms 1664 KB Output is correct
3 Correct 25 ms 1816 KB Output is correct
4 Correct 51 ms 2168 KB Output is correct
5 Correct 75 ms 3832 KB Output is correct
6 Correct 76 ms 3832 KB Output is correct
7 Correct 76 ms 3928 KB Output is correct
8 Correct 74 ms 3960 KB Output is correct
9 Correct 72 ms 3716 KB Output is correct
10 Correct 72 ms 3704 KB Output is correct
11 Correct 76 ms 3704 KB Output is correct
12 Correct 75 ms 3704 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 103 ms 3064 KB Output is correct
2 Correct 139 ms 3320 KB Output is correct
3 Correct 125 ms 2680 KB Output is correct
4 Correct 135 ms 2788 KB Output is correct
5 Correct 159 ms 5112 KB Output is correct
6 Correct 172 ms 5112 KB Output is correct
7 Correct 168 ms 5112 KB Output is correct
8 Correct 209 ms 5112 KB Output is correct
9 Correct 190 ms 4988 KB Output is correct
10 Correct 222 ms 5112 KB Output is correct
11 Correct 163 ms 4984 KB Output is correct
12 Correct 298 ms 5112 KB Output is correct