답안 #750388

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
750388 2023-05-29T12:59:07 Z Yazan_SA Sterilizing Spray (JOI15_sterilizing) C++17
100 / 100
832 ms 8648 KB
#include<bits/stdc++.h>
#include <cstdio>
#define endl "\n"
/*/*(last choice)*/ #define int long long
#define all(x) x.begin(), x.end()
#define ll long long
#define tsts int t; cin>>t; while(t--)
#define start cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
using namespace std;
int tree[10000005];
set<int>st;
vector<int>v;
int k;
void update(int l, int r, int idx, int val, int node=1)
{
    if(l>idx || r<idx)
        return;
    if(l==r)
    {
        tree[node]=val;
        return;
    }
    int mid=(l+r)/2;
    update(l,mid,idx,val,node*2);
    update(mid+1,r,idx,val,node*2+1);
    tree[node]=tree[node*2]+tree[node*2+1];
}
void upd(int l, int r)
{
    auto it=st.lower_bound(l);
    auto it2=st.upper_bound(r);
    vector<int>er;
    for(; it!=it2; it++)
    {
        v[*it]/=k;
        update(0,1e6,*it,v[*it]);
        if(v[*it]==0)
            er.push_back(*it);
    }
    for(auto c:er)
        st.erase(c);
}
int gett(int l, int r, int ul, int ur, int node=1)
{
    if(l>ur || r<ul)
        return 0;
    if(l>=ul && r<=ur)
        return tree[node];
    int mid=(l+r)/2;
    return (gett(l,mid,ul,ur,node*2) + gett(mid+1,r,ul,ur,node*2+1));
}
signed main()
{
    start
    //freopen("codeblocksinput.txt", "w", stdout);
    int n,q;
    cin>>n>>q>>k;
    v.resize(n);
    for(int i=0; i<n; i++)
    {
        cin>>v[i];
        update(0,1e6,i,v[i]);
        if(v[i]>0)
            st.insert(i);
    }
    while(q--)
    {
        int x, l ,r;
        cin>>x>>l>>r;
        if(x==1)
        {
            v[l-1]=r;
            if(l>0)
                st.insert(l-1);
            update(0,1e6,l-1,r);
        }
        else if(x==2)
        {
            if(k==1)
                continue;
            upd(l-1,r-1);
        }
        else
            cout<<gett(0,1e6,l-1,r-1)<<endl;
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 4 ms 468 KB Output is correct
4 Correct 19 ms 480 KB Output is correct
5 Correct 13 ms 596 KB Output is correct
6 Correct 10 ms 596 KB Output is correct
7 Correct 18 ms 600 KB Output is correct
8 Correct 12 ms 596 KB Output is correct
9 Correct 15 ms 600 KB Output is correct
10 Correct 12 ms 596 KB Output is correct
11 Correct 12 ms 596 KB Output is correct
12 Correct 12 ms 592 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 67 ms 4300 KB Output is correct
2 Correct 62 ms 3076 KB Output is correct
3 Correct 80 ms 6056 KB Output is correct
4 Correct 133 ms 7760 KB Output is correct
5 Correct 116 ms 7964 KB Output is correct
6 Correct 107 ms 7904 KB Output is correct
7 Correct 106 ms 7960 KB Output is correct
8 Correct 107 ms 7888 KB Output is correct
9 Correct 104 ms 7888 KB Output is correct
10 Correct 141 ms 8004 KB Output is correct
11 Correct 105 ms 7988 KB Output is correct
12 Correct 101 ms 7980 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 22 ms 724 KB Output is correct
2 Correct 29 ms 2516 KB Output is correct
3 Correct 36 ms 2664 KB Output is correct
4 Correct 62 ms 1792 KB Output is correct
5 Correct 94 ms 5336 KB Output is correct
6 Correct 119 ms 5264 KB Output is correct
7 Correct 84 ms 5960 KB Output is correct
8 Correct 99 ms 5420 KB Output is correct
9 Correct 98 ms 5784 KB Output is correct
10 Correct 107 ms 5680 KB Output is correct
11 Correct 111 ms 5676 KB Output is correct
12 Correct 119 ms 5676 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 236 ms 4268 KB Output is correct
2 Correct 255 ms 4308 KB Output is correct
3 Correct 423 ms 3708 KB Output is correct
4 Correct 236 ms 2928 KB Output is correct
5 Correct 393 ms 7824 KB Output is correct
6 Correct 482 ms 7796 KB Output is correct
7 Correct 389 ms 7772 KB Output is correct
8 Correct 748 ms 7884 KB Output is correct
9 Correct 529 ms 8648 KB Output is correct
10 Correct 663 ms 8436 KB Output is correct
11 Correct 406 ms 8648 KB Output is correct
12 Correct 832 ms 8200 KB Output is correct