Submission #167130

# Submission time Handle Problem Language Result Execution time Memory
167130 2019-12-06T06:01:23 Z rzbt Hedgehog Daniyar and Algorithms (IZhO19_sortbooks) C++14
30 / 100
2244 ms 140792 KB
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define MAXN 1000006
typedef long long ll;


using namespace std;

ll n,m;
vector<ll> s;
vector<pair<pair<ll,ll>,ll> > query[MAXN];
vector<ll> gube[MAXN];
ll niz[MAXN],res[MAXN];
ll tr[MAXN];
ll seg[4*MAXN];
void dodaj(ll l,ll d,ll p,ll k,ll x){
    if(l==d){
        seg[k]=x;
        return;
    }
    ll mid=(l+d)/2;
    if(p<=mid)dodaj(l,mid,p,k+k,x);
    else dodaj(mid+1,d,p,k+k+1,x);
    seg[k]=max(seg[k+k],seg[k+k+1]);
}

ll dobij(ll l,ll d,ll tl,ll td,ll k){
    if(l>td || d<tl)return 0;
    if(l>=tl && d<=td)return seg[k];
    ll mid=(l+d)/2;
    return max(dobij(l,mid,tl,td,k+k),
            dobij(mid+1,d,tl,td,k+k+1));

}

void izgradi(ll l,ll d,ll k){
    if(l==d){
        seg[k]=tr[l];
        return;
    }
    ll mid=(l+d)/2;
    izgradi(l,mid,k+k);
    izgradi(mid+1,d,k+k+1);
    seg[k]=max(seg[k+k],seg[k+k+1]);

}

int main()
{
    scanf("%lld %lld", &n, &m);
    for(ll i=1;i<=n;i++){
        scanf("%lld",niz+i);
        while(!s.empty() && niz[s.back()] <= niz[i])s.pop_back();
        if(s.empty())s.pb(i);
        else{
            ll o=s.back();
            gube[o].pb(i);
            tr[i]=niz[i]+niz[o];
            s.push_back(i);
        }
    }
    izgradi(1,n,1);
    for(ll i=1;i<=m;i++){
        ll t1,t2,t3;
        scanf("%lld %lld %lld", &t1, &t2, &t3);
        query[t1].pb(mp(mp(t2,t3), i));
    }
    for(ll i=1;i<=m;i++){
        for(auto x:query[i]){
            if(dobij(1,n,i,x.F.F,1)<=x.F.S)res[x.S]=1;
            else res[x.S]=0;
        }
        for(auto x:gube[i])
            dodaj(1,n,x,1,0);
    }
    for(ll i=1;i<=m;i++)printf("%lld\n",res[i]);

    return 0;//
}

Compilation message

sortbooks.cpp: In function 'int main()':
sortbooks.cpp:54:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%lld %lld", &n, &m);
     ~~~~~^~~~~~~~~~~~~~~~~~~~~
sortbooks.cpp:56:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%lld",niz+i);
         ~~~~~^~~~~~~~~~~~~~
sortbooks.cpp:69:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%lld %lld %lld", &t1, &t2, &t3);
         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 47 ms 47352 KB Output is correct
2 Correct 45 ms 47352 KB Output is correct
3 Correct 46 ms 47352 KB Output is correct
4 Correct 49 ms 47480 KB Output is correct
5 Incorrect 46 ms 47352 KB Output isn't correct
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 47 ms 47352 KB Output is correct
2 Correct 45 ms 47352 KB Output is correct
3 Correct 46 ms 47352 KB Output is correct
4 Correct 49 ms 47480 KB Output is correct
5 Incorrect 46 ms 47352 KB Output isn't correct
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2228 ms 140784 KB Output is correct
2 Correct 2228 ms 140792 KB Output is correct
3 Correct 2224 ms 140600 KB Output is correct
4 Correct 2244 ms 140376 KB Output is correct
5 Correct 1880 ms 114044 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 211 ms 57092 KB Output is correct
2 Correct 216 ms 57596 KB Output is correct
3 Correct 177 ms 54648 KB Output is correct
4 Correct 175 ms 54556 KB Output is correct
5 Correct 175 ms 54520 KB Output is correct
6 Correct 138 ms 54776 KB Output is correct
7 Correct 139 ms 54828 KB Output is correct
8 Correct 159 ms 55392 KB Output is correct
9 Correct 100 ms 51268 KB Output is correct
10 Correct 155 ms 55156 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 47 ms 47352 KB Output is correct
2 Correct 45 ms 47352 KB Output is correct
3 Correct 46 ms 47352 KB Output is correct
4 Correct 49 ms 47480 KB Output is correct
5 Incorrect 46 ms 47352 KB Output isn't correct
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 47 ms 47352 KB Output is correct
2 Correct 45 ms 47352 KB Output is correct
3 Correct 46 ms 47352 KB Output is correct
4 Correct 49 ms 47480 KB Output is correct
5 Incorrect 46 ms 47352 KB Output isn't correct
6 Halted 0 ms 0 KB -