Submission #396066

# Submission time Handle Problem Language Result Execution time Memory
396066 2021-04-29T12:15:57 Z teehandsome Wall (IOI14_wall) C++11
8 / 100
3000 ms 14036 KB
#include "wall.h"
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define endl '\n'
#define INF 1e9+7
#define all(x) x.begin(),x.end()
using namespace std;
using namespace __gnu_pbds;
using ll=long long;
using pii=pair<int,int>;
using ppi=pair<int,pii>;
using oset=tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>;

template<typename T>
void _print(vector<T> x) {cerr<<"{"; for(auto e:x) cerr<<e<<","; cerr<<"}";}
void _print(pii x) {cerr<<"{"<<x.first<<","<<x.second<<"}";}
template<typename T>
void _print(T x) {cerr<<x;}

void dbg() {cerr<<endl;}
template<typename Head,typename... Tail>
void dbg(Head H,Tail... T) {
    _print(H);
    if(sizeof...(T)) cerr<<",";
    else cerr<<"\"]";
    dbg(T...);
}
#define debug(...) cerr<<"["<<#__VA_ARGS__<<"]:[\"",dbg(__VA_ARGS__)

//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int mxn=2e6+10;
int n,k;

struct dt {
    int mn,mx;
};

dt t[3*mxn];
pii flag[3*mxn];

void push(int v,int tl,int tr) {
    if(flag[v].first==0) return;
    if(flag[v].first==1) {
        t[v].mn=max(t[v].mn,flag[v].second);
        t[v].mx=max(t[v].mx,flag[v].second);
    }
    else {
        t[v].mn=min(t[v].mn,flag[v].second);
        t[v].mx=min(t[v].mx,flag[v].second);
    }
    if(tl!=tr) {
        int mid=(tl+tr)/2;
        push(2*v,tl,mid);
        push(2*v+1,mid+1,tr);
        flag[2*v]=flag[2*v+1]=flag[v];
    }
//    if(tl!=tr) flag[2*v]=flag[2*v+1]=flag[v];
    flag[v]={0,0};
}

void update(int cmd,int v,int tl,int tr,int l,int r,int val) {
    //1=max 2=min
    if(tl>tr or tl>r or tr<l) return;
    push(v,tl,tr);
    if(tl>=l and tr<=r) {
        flag[v]={cmd,val};
//        push(v,tl,tr);
        return;
    }
    int mid=(tl+tr)/2;
    update(cmd,2*v,tl,mid,l,r,val);
    update(cmd,2*v+1,mid+1,tr,l,r,val);
    t[v].mn=min(t[2*v].mn,t[2*v+1].mn);
    t[v].mx=max(t[2*v].mx,t[2*v+1].mx);
}

int get(int v,int tl,int tr,int idx) {
    push(v,tl,tr);
    if(tl==tr and idx==tl) {
        assert(t[v].mn==t[v].mx);
        return t[v].mx;
    }
    int mid=(tl+tr)/2;
    if(idx<=mid) return get(2*v,tl,mid,idx);
    return get(2*v+1,mid+1,tr,idx);
}

void buildWall(int N, int K, int op[], int left[], int right[], int height[], int finalHeight[]){
    n=N,k=K;
    for(int i=0;i<k;i++) {
        update(op[i],1,0,n-1,left[i],right[i],height[i]);
//        vector<int> temp;
//        for(int j=0;j<n;j++) {
//            temp.push_back(get(1,0,n-1,j));
//        }
//        debug(temp);
    }
    for(int i=0;i<n;i++) {
        finalHeight[i]=get(1,0,n-1,i);
    }
}


# Verdict Execution time Memory Grader output
1 Correct 1 ms 208 KB Output is correct
2 Correct 3 ms 332 KB Output is correct
3 Correct 5 ms 332 KB Output is correct
4 Correct 282 ms 1008 KB Output is correct
5 Correct 252 ms 1012 KB Output is correct
6 Correct 263 ms 1012 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 161 ms 14020 KB Output is correct
3 Execution timed out 3081 ms 8448 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 2 ms 332 KB Output is correct
3 Correct 5 ms 332 KB Output is correct
4 Correct 267 ms 1024 KB Output is correct
5 Correct 256 ms 1020 KB Output is correct
6 Correct 255 ms 972 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 164 ms 13864 KB Output is correct
9 Execution timed out 3090 ms 8436 KB Time limit exceeded
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 2 ms 332 KB Output is correct
3 Correct 5 ms 364 KB Output is correct
4 Correct 262 ms 1068 KB Output is correct
5 Correct 257 ms 1020 KB Output is correct
6 Correct 254 ms 1016 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 162 ms 14036 KB Output is correct
9 Execution timed out 3072 ms 8444 KB Time limit exceeded
10 Halted 0 ms 0 KB -