| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 333313 | GioChkhaidze | Sterilizing Spray (JOI15_sterilizing) | C++14 | 5096 ms | 5868 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define Tree int h,int l,int r
#define Left (h<<1),l,(l+r)>>1
#define Right ((h<<1)|1),((l+r)>>1)+1,r
#define ll long long
using namespace std;
const int N=1e5+5;
int n,q,k;
int a[N];
ll v[4*N];
void Build(Tree) {
if (l==r) {
v[h]=a[l];
return ;
}
Build(Left);
Build(Right);
v[h]=v[(h<<1)]+v[((h<<1)|1)];
}
int t,id,vl;
void Up(Tree) {
if (id<l || r<id) return ;
if (l==id && r==id) {
v[h]=a[l];
return ;
}
Up(Left);
Up(Right);
v[h]=v[(h<<1)]+v[((h<<1)|1)];
}
int L,R;
void Upd(Tree) {
if (R<l || r<L) return ;
if (l==r) {
v[h]/=k;
return ;
}
Upd(Left);
Upd(Right);
v[h]=v[(h<<1)]+v[((h<<1)|1)];
}
ll Get(Tree) {
if (R<l || r<L) return 0;
if (L<=l && r<=R) return v[h];
return Get(Left)+Get(Right);
}
main () {
ios::sync_with_stdio(false);
cin.tie(NULL),cout.tie(NULL);
cin>>n>>q>>k;
for (int i=1; i<=n; i++) {
cin>>a[i];
}
Build(1,1,n);
for (int i=1; i<=q; i++) {
cin>>t;
if (t==1) {
cin>>id>>vl;
a[id]=vl;
Up(1,1,n);
}
else
if (t==2) {
cin>>L>>R;
if (k==1) continue;
Upd(1,1,n);
}
else
if (t==3) {
cin>>L>>R;
cout<<Get(1,1,n)<<"\n";
}
}
}컴파일 시 표준 에러 (stderr) 메시지
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
