Submission #167127

# Submission time Handle Problem Language Result Execution time Memory
167127 2019-12-06T05:51:27 Z rzbt Hedgehog Daniyar and Algorithms (IZhO19_sortbooks) C++14
30 / 100
2134 ms 107288 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;

int n,m;
vector<int> s;
vector<pair<pair<int,int>,int> > query[MAXN];
vector<int> gube[MAXN];
int niz[MAXN],res[MAXN];
int tr[MAXN];
int seg[4*MAXN];
void dodaj(int l,int d,int p,int k,int x){
    if(l==d){
        seg[k]=x;
        return;
    }
    int 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]);
}

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

}

void izgradi(int l,int d,int k){
    if(l==d){
        seg[k]=tr[l];
        return;
    }
    int 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("%d %d", &n, &m);
    for(int i=1;i<=n;i++){
        scanf("%d",niz+i);
        while(!s.empty() && niz[s.back()] <= niz[i])s.pop_back();
        if(s.empty())s.pb(i);
        else{
            int o=s.back();
            gube[o].pb(i);
            tr[i]=niz[i]+niz[o];
            s.push_back(i);
        }
    }
    izgradi(1,n,1);
    for(int i=1;i<=m;i++){
        int t1,t2,t3;
        scanf("%d %d %d", &t1, &t2, &t3);
        query[t1].pb(mp(mp(t2,t3), i));
    }
    for(int 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(int i=1;i<=m;i++)printf("%d\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("%d %d", &n, &m);
     ~~~~~^~~~~~~~~~~~~~~~~
sortbooks.cpp:56:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d",niz+i);
         ~~~~~^~~~~~~~~~~~
sortbooks.cpp:69:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d %d %d", &t1, &t2, &t3);
         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 50 ms 47352 KB Output is correct
2 Correct 47 ms 47224 KB Output is correct
3 Correct 50 ms 47352 KB Output is correct
4 Correct 50 ms 47324 KB Output is correct
5 Incorrect 49 ms 47396 KB Output isn't correct
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 50 ms 47352 KB Output is correct
2 Correct 47 ms 47224 KB Output is correct
3 Correct 50 ms 47352 KB Output is correct
4 Correct 50 ms 47324 KB Output is correct
5 Incorrect 49 ms 47396 KB Output isn't correct
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2133 ms 107272 KB Output is correct
2 Correct 2133 ms 107288 KB Output is correct
3 Correct 2123 ms 107188 KB Output is correct
4 Correct 2134 ms 107232 KB Output is correct
5 Correct 1790 ms 87392 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 203 ms 53496 KB Output is correct
2 Correct 181 ms 53368 KB Output is correct
3 Correct 163 ms 51544 KB Output is correct
4 Correct 170 ms 51448 KB Output is correct
5 Correct 170 ms 51576 KB Output is correct
6 Correct 134 ms 51008 KB Output is correct
7 Correct 133 ms 51060 KB Output is correct
8 Correct 155 ms 51756 KB Output is correct
9 Correct 98 ms 49316 KB Output is correct
10 Correct 154 ms 51552 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 50 ms 47352 KB Output is correct
2 Correct 47 ms 47224 KB Output is correct
3 Correct 50 ms 47352 KB Output is correct
4 Correct 50 ms 47324 KB Output is correct
5 Incorrect 49 ms 47396 KB Output isn't correct
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 50 ms 47352 KB Output is correct
2 Correct 47 ms 47224 KB Output is correct
3 Correct 50 ms 47352 KB Output is correct
4 Correct 50 ms 47324 KB Output is correct
5 Incorrect 49 ms 47396 KB Output isn't correct
6 Halted 0 ms 0 KB -