Submission #948350

# Submission time Handle Problem Language Result Execution time Memory
948350 2024-03-18T04:39:10 Z irmuun Wall (IOI14_wall) C++17
100 / 100
564 ms 104788 KB
#include<bits/stdc++.h>
 
using namespace std;
 
#define ll long long
#define pb push_back
#define ff first
#define ss second
#define all(s) s.begin(),s.end()
#define rall(s) s.rbegin(),s.rend()

struct segtree{
    int n;
    vector<int>d,u,ans;
    segtree(int n):n(n){
        d.resize(4*n);
        u.resize(4*n);
        ans.resize(n);
        build(1,0,n-1);
    }
    void combine(int node,int D,int U){
        d[node]=min(d[node],D);
        d[node]=max(d[node],U);
        u[node]=max(u[node],U);
        u[node]=min(u[node],D);
    }
    void build(int node,int l,int r){
        if(l==r){
            d[node]=1e9;
            u[node]=0;
            return;
        }
        int mid=(l+r)/2;
        build(node*2,l,mid);
        build(node*2+1,mid+1,r);
    }
    void update(int node,int l,int r,int L,int R,int val,int type){
        if(L>R||r<L||R<l) return;
        if(L<=l&&r<=R){
            if(type==1){
                d[node]=max(d[node],val);
                u[node]=max(u[node],val);
            }
            else{
                d[node]=min(d[node],val);
                u[node]=min(u[node],val);
            }
            return;
        }
        combine(node*2,d[node],u[node]);
        combine(node*2+1,d[node],u[node]);
        d[node]=1e9;
        u[node]=0;
        int mid=(l+r)/2;
        update(node*2,l,mid,L,R,val,type);
        update(node*2+1,mid+1,r,L,R,val,type);
    }
    void findAns(int node,int l,int r){
        if(l==r){
            ans[l]=min(d[node],u[node]);
            return;
        }
        combine(node*2,d[node],u[node]);
        combine(node*2+1,d[node],u[node]);
        int mid=(l+r)/2;
        findAns(node*2,l,mid);
        findAns(node*2+1,mid+1,r);
    }
    vector<int>f(){
        return ans;
    }
};
 
void buildWall(int n, int k, int op[], int l[], int r[], int h[], int H[]){
    segtree sg(n);
    for(int i=0;i<k;i++){
        sg.update(1,0,n-1,l[i],r[i],h[i],op[i]);
    }
    sg.findAns(1,0,n-1);
    vector<int>v=sg.f();
    for(int i=0;i<n;i++){
        H[i]=v[i];
    }
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 2 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 4 ms 860 KB Output is correct
5 Correct 4 ms 860 KB Output is correct
6 Correct 5 ms 856 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 109 ms 13868 KB Output is correct
3 Correct 123 ms 6888 KB Output is correct
4 Correct 347 ms 22376 KB Output is correct
5 Correct 220 ms 22716 KB Output is correct
6 Correct 235 ms 21148 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 448 KB Output is correct
3 Correct 1 ms 444 KB Output is correct
4 Correct 4 ms 860 KB Output is correct
5 Correct 4 ms 1008 KB Output is correct
6 Correct 4 ms 860 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 149 ms 13912 KB Output is correct
9 Correct 129 ms 8172 KB Output is correct
10 Correct 338 ms 22112 KB Output is correct
11 Correct 226 ms 22704 KB Output is correct
12 Correct 225 ms 20936 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 112 ms 13912 KB Output is correct
15 Correct 20 ms 2140 KB Output is correct
16 Correct 334 ms 22160 KB Output is correct
17 Correct 226 ms 21588 KB Output is correct
18 Correct 217 ms 21584 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 2 ms 568 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 4 ms 956 KB Output is correct
5 Correct 4 ms 860 KB Output is correct
6 Correct 4 ms 860 KB Output is correct
7 Correct 1 ms 600 KB Output is correct
8 Correct 109 ms 14004 KB Output is correct
9 Correct 121 ms 8056 KB Output is correct
10 Correct 331 ms 22168 KB Output is correct
11 Correct 217 ms 22708 KB Output is correct
12 Correct 212 ms 21072 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 112 ms 14020 KB Output is correct
15 Correct 20 ms 2132 KB Output is correct
16 Correct 365 ms 22352 KB Output is correct
17 Correct 219 ms 21588 KB Output is correct
18 Correct 218 ms 21576 KB Output is correct
19 Correct 515 ms 104784 KB Output is correct
20 Correct 509 ms 104768 KB Output is correct
21 Correct 564 ms 104736 KB Output is correct
22 Correct 509 ms 104588 KB Output is correct
23 Correct 505 ms 104784 KB Output is correct
24 Correct 506 ms 104772 KB Output is correct
25 Correct 518 ms 104764 KB Output is correct
26 Correct 512 ms 104772 KB Output is correct
27 Correct 519 ms 104788 KB Output is correct
28 Correct 509 ms 104696 KB Output is correct
29 Correct 510 ms 104768 KB Output is correct
30 Correct 518 ms 104784 KB Output is correct