답안 #954402

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
954402 2024-03-27T19:19:11 Z ziyad_alharbi Sterilizing Spray (JOI15_sterilizing) C++17
5 / 100
36 ms 4404 KB
#include <bits/stdc++.h>
using namespace std;
vector<long long>sg,a(100005);
int n,sz;
void is()
{
    for(sz=1;sz<n;sz*=2);
    sg.resize(sz*2,0);
}
void up(int i,int v)
{
    i+=sz;
    sg[i]=v;
    for(i/=2;i>0;i/=2)
    {
        sg[i]=sg[i*2]+sg[i*2+1];
    }
}
long long q(int v,int lw,int h,int l,int r)
{
    if(lw<=l&&r<=h)
    {
        return sg[v];
    }
    else if(l>=h||lw>=r)
    {
        return 0;
    }
    else
    {
        int m=(l+r)/2;
        long long f=q(v*2,lw,h,l,m),s=q(v*2+1,lw,h,m,r);
        return f+s;
    }
}
signed main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int t=1;
    //cin>>t;
    while(t--)
    {
        int qr,k;
        cin>>n>>qr>>k;
        is();
        for(int x=0;x<n;x++)
        {
            cin>>a[x];
            up(x,a[x]);
        }
        if(n<=3000&&qr<=3000)
        {
            while(qr--)
            {
                int t,l,r;
                cin>>t>>l>>r;
                if(t==1)a[l-1]=r;
                if(t==2)
                {
                    for(int x=l-1;x<r;x++)a[x]/=k;
                }
                if(t==3)
                {
                    long long s=0;
                    for(int x=l-1;x<r;x++)s+=a[x];
                    cout<<s<<'\n';
                }
            }
        }
        else
        {
            while(qr--)
            {
                int t,l,r;
                cin>>t>>l>>r;
                if(t==1)up(l-1,r);
                if(t==3)cout<<q(1,l-1,r,0,sz);
            }
        }
    }
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1116 KB Output is correct
2 Correct 2 ms 1264 KB Output is correct
3 Correct 2 ms 1116 KB Output is correct
4 Correct 3 ms 1112 KB Output is correct
5 Correct 5 ms 1372 KB Output is correct
6 Correct 5 ms 1368 KB Output is correct
7 Correct 5 ms 1368 KB Output is correct
8 Correct 5 ms 1372 KB Output is correct
9 Correct 5 ms 1372 KB Output is correct
10 Correct 5 ms 1368 KB Output is correct
11 Correct 5 ms 1372 KB Output is correct
12 Correct 5 ms 1368 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 36 ms 4404 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 11 ms 1636 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 29 ms 4072 KB Output isn't correct
2 Halted 0 ms 0 KB -