Submission #466706

# Submission time Handle Problem Language Result Execution time Memory
466706 2021-08-20T11:48:38 Z Urvuk3 Watering can (POI13_kon) C++17
0 / 100
463 ms 20592 KB
#include <bits/stdc++.h>

using namespace std;

#define ll long long
const int MAXN=3e5+5,MAXM=40,INF=1e9,MOD=1e9+7;
#define fi first
#define se second
#define pll pair<ll,ll>
#define pii pair<int,int>
#define mid (l+r)/2
#define sz(a) int((a).size())
#define all(a) a.begin(),a.end()
#define mod 1000000007LL
#define pb push_back
#define endl "\n"
#define PRINT(x) cerr<<#x<<'-'<<x<<endl<<flush;
#define PRINTBITS(x) {bitset<5> f=x; cerr<<#x<<'-'<<f<<endl<<flush;}
#define getunique(v) {sort(all(v)); v.erase(unique(all(v)), v.end());}
#define pb push_back
#define pf push_front
#define ppf pop_front
#define ppb pop_back

ll N,m,K,q,x,y,z,res=0,l,r;
string s,t;
vector<int> a;

int lazy[4*MAXN];
pii seg1[4*MAXN]; // cuvacu par gde je druga vrdnost index maximuma
int seg2[4*MAXN]; // cuvacu 1 u listu ako je drvo zrelo

void propagate1(int node,int l,int r){
    seg1[node].fi+=lazy[node];
    if(l<r){
        lazy[2*node]+=lazy[node];
        lazy[2*node+1]+=lazy[node];
    }
    lazy[node]=0;
}

void update1(int node,int l,int r,int L,int R,int val){
    propagate1(node,l,r);
    if(l>r  || l>R || r<L) return;
    if(L<=l && r<=R){
        lazy[node]+=val;
        propagate1(node,l,r);
        return;
    }
    update1(2*node,l,mid,L,R,val);
    update1(2*node+1,mid+1,r,L,R,val);
    seg1[node]=max(seg1[2*node],seg1[2*node+1]);
}

pii query1(int node,int l,int r,int L,int R){
    propagate1(node,l,r);
    if(l>r || l>R || r<L) return {-INF,-INF};
    if(L<=l && r<=R) return seg1[node];
    return max(query1(2*node,l,mid,L,R),query1(2*node+1,mid+1,r,L,R));
}

void update2(int node,int l,int r,int idx){
    if(l==r){
        seg2[node]++;
        return;
    }
    if(idx<=mid) update2(2*node,l,mid,idx);
    else update2(2*node+1,mid+1,r,idx);
    seg2[node]=seg2[2*node]+seg2[2*node+1];
}

int query2(int node,int l,int r,int L,int R){
    if(L<=l && r<=R) return seg2[node];
    ll ret=0;
    if(L<=mid) ret+=query2(node,l,mid,L,R);
    if(R>mid) ret+=query2(node,mid+1,r,L,R);
    return ret;
}

void init(int node,int l,int r){
    if(l==r){
        if(a[l]>=K){
            seg2[node]=1;
            seg1[node]={-INF,-INF};
        }
        else{
            seg2[node]=0;
            seg1[node]={a[l],l};
        }
        return;
    }
    init(2*node,l,mid);
    init(2*node+1,mid+1,r);
    seg1[node]=max(seg1[2*node],seg1[2*node+1]);
    seg2[node]=seg2[2*node]+seg2[2*node+1];
}

void inicjuj(int n, int k, int *D){
    K=k;
    N=n;
    a.pb(INF);
    for(int i=1;i<=N;i++){
        a.pb(D[i]);
    }
    init(1,1,N);
}

void podlej(int a, int b){
    ++a; ++b;
    update1(1,1,N,a,b,+1);
    while(true){
        pii qu=query1(1,1,N,1,N);
        if(qu.fi<K) break;
        update2(1,1,N,qu.se);
        update1(1,1,N,qu.se,qu.se,-INF);
    }
}

int dojrzale(int a, int b){
    ++a; ++b;
    return query2(1,1,N,a,b);
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 1484 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 1484 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 50 ms 2948 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 69 ms 4060 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 122 ms 6404 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 216 ms 6960 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 251 ms 7004 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 325 ms 11796 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 463 ms 20524 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 419 ms 20592 KB Output isn't correct
2 Halted 0 ms 0 KB -