답안 #257901

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
257901 2020-08-05T03:52:16 Z Autoratch Meteors (POI11_met) C++14
0 / 100
5221 ms 60176 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];
int 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);
}

int 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+1;
    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]) 
            {
                int 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) 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];
                  ^
# 결과 실행 시간 메모리 Grader output
1 Incorrect 31 ms 25080 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 22 ms 25088 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 621 ms 28656 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 474 ms 29348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 234 ms 28656 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 510 ms 28448 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 5154 ms 60176 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 5221 ms 57632 KB Output isn't correct
2 Halted 0 ms 0 KB -