| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 219263 | MKopchev | Sterilizing Spray (JOI15_sterilizing) | C++14 | 1485 ms | 9336 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
const int nmax=1e5+42;
int n,q,k,inp[nmax];
long long fenwick[nmax];
void update(int pos,int val)
{
while(pos<=n)
{
fenwick[pos]+=val;
pos=pos+(pos&(-pos));
}
}
long long sum(int pos)
{
long long ret=0;
while(pos)
{
ret=ret+fenwick[pos];
pos=pos-(pos&(-pos));
}
return ret;
}
long long query(int l,int r)
{
return sum(r)-sum(l-1);
}
set<int> non_zero;
void make(int pos,int val)
{
//cout<<"make "<<pos<<" "<<val<<endl;
if(inp[pos])non_zero.erase(pos);
update(pos,-inp[pos]);
inp[pos]=val;
if(inp[pos])non_zero.insert(pos);
update(pos,inp[pos]);
}
int main()
{
scanf("%i%i%i",&n,&q,&k);
for(int i=1;i<=n;i++)
{
scanf("%i",&inp[i]);
int was=inp[i];
inp[i]=0;
make(i,was);
if(inp[i])non_zero.insert(i);
}
int type,l,r;
for(int i=1;i<=q;i++)
{
scanf("%i%i%i",&type,&l,&r);
if(type==1)
{
make(l,r);
}
if(type==2&&k!=1)
{
int lst_used=l-1;
while(1)
{
set<int>::iterator it=non_zero.upper_bound(lst_used);
if(it==non_zero.end())break;
int current=*it;
if(current>r)break;
make(current,inp[current]/k);
lst_used=current;
}
}
if(type==3)
{
printf("%lld\n",query(l,r));
}
/*
for(int j=1;j<=n;j++)
cout<<query(j,j)<<" ";cout<<endl;
cout<<"---"<<endl;
*/
}
return 0;
}
컴파일 시 표준 에러 (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... | ||||
