Submission #257903

# Submission time Handle Problem Language Result Execution time Memory
257903 2020-08-05T03:57:41 Z Autoratch Meteors (POI11_met) C++14
0 / 100
6000 ms 58736 KB
#include <bits/stdc++.h>
using namespace std;

const int N = 1 << 19;

int n,m,q;
int bl[N],need[N];
vector<int> wh[N];
long long tree[N << 1],lazy[N << 1];
int l[N],r[N],ans[N];
vector<int> ask[N];
vector<tuple<int,int,int> > inp;

void pushlz(int l,int r,int idx)
{
    if(!lazy[idx]) return;
    if(l==r) tree[idx]+=lazy[idx];
    else lazy[idx*2]+=lazy[idx],lazy[idx*2+1]+=lazy[idx];
    lazy[idx] = 0;
}

void build(int l,int r,int idx)
{
    tree[idx] = lazy[idx] = 0;
    if(l==r) return;
    int m = (l+r)/2;
    build(l,m,idx*2),build(m+1,r,idx+2+1);
}

void update(int l,int r,int idx,int x,int y,int k)
{
    pushlz(l,r,idx);
    if(x>r or y<l) return;
    if(x<=l and y>=r)
    {
        lazy[idx]+=k;
        pushlz(l,r,idx);
        return;
    }
    int m = (l+r)/2;
    update(l,m,idx*2,x,y,k),update(m+1,r,idx*2+1,x,y,k);
}

long long read(int l,int r,int idx,int x)
{
    pushlz(l,r,idx);
    if(x>r or x<l) return 0;
    if(l==r) return tree[idx];
    int m = (l+r)/2;
    return read(l,m,idx*2,x)+read(m+1,r,idx*2+1,x);
}

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);

    cin >> n >> m;
    for(int i = 1;i <= m;i++) cin >> bl[i],wh[bl[i]].push_back(i);
    for(int i = 1;i <= n;i++) cin >> need[i];
    cin >> q;
    for(int i = 1;i <= q;i++)
    {
        int l,r,k;
        cin >> l >> r >> k;
        inp.push_back({l,r,k});
    }
    for(int i = 1;i <= n;i++) l[i] = 1,r[i] = q;
    while(true)
    {
        bool done = true;
        for(int i = 1;i <= n;i++) if(l[i]!=r[i]) done = false,ask[(l[i]+r[i])/2].push_back(i);
        if(done) break;
        build(1,m,1);
        for(int i = 1;i <= q;i++)
        {
            auto [ll,rr,k] = inp[i-1];
            if(ll<=rr) update(1,m,1,ll,rr,k);
            else update(1,m,1,1,rr,k),update(1,m,1,ll,m,k);
            for(int x : ask[i]) 
            {
                long long tmp = 0;
                for(int y : wh[x]) tmp+=read(1,m,1,y);
                int m = (l[x]+r[x])/2;
                if(tmp>=need[x]) r[x] = m;
                else l[x] = m+1;
            }
            ask[i].clear();
        }
    }
    for(int i = 1;i <= n;i++)
    {
        if(l[i]==q)
        {
            int tmp = 0;
            for(int x : wh[i]) tmp+=read(1,m,1,x);
            if(tmp<need[i]) l[i] = -1;
        }
    }
    for(int i = 1;i <= n;i++) if(l[i]!=-1) cout << l[i] << '\n'; else cout << "NIE\n";
}

Compilation message

met.cpp: In function 'int main()':
met.cpp:76:18: warning: decomposition declaration only available with -std=c++1z or -std=gnu++1z
             auto [ll,rr,k] = inp[i-1];
                  ^
# Verdict Execution time Memory Grader output
1 Incorrect 19 ms 25088 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 20 ms 25088 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 467 ms 28660 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 480 ms 29348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 228 ms 28784 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 510 ms 28324 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 6038 ms 58736 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 6035 ms 57264 KB Time limit exceeded
2 Halted 0 ms 0 KB -