Submission #849262

# Submission time Handle Problem Language Result Execution time Memory
849262 2023-09-14T10:20:59 Z abcvuitunggio Wall (IOI14_wall) C++17
100 / 100
720 ms 140176 KB
#include "wall.h"
#include <bits/stdc++.h>
using namespace std;
struct T{
    int l,r;
}st[8000001],lazy[8000001];
int res[2000001];
T operator +(T a, T b){
    return {min(a.l,b.l),max(a.r,b.r)};
}
T operator *(T a, T b){
    return {min(max(a.l,b.l),b.r),min(max(a.r,b.l),b.r)};
}
void down(int node, int l, int r){
    if (l==r)
        return;
    st[node<<1]=st[node<<1]*lazy[node];
    lazy[node<<1]=lazy[node<<1]*lazy[node];
    st[node<<1|1]=st[node<<1|1]*lazy[node];
    lazy[node<<1|1]=lazy[node<<1|1]*lazy[node];
    lazy[node]={0,100000};
}
void update(int node, int l, int r, int u, int v, T t){
    if (l>v||r<u||l>r)
        return;
    if (l>=u&&r<=v){
        st[node]=st[node]*t;
        lazy[node]=lazy[node]*t;
        return;
    }
    down(node,l,r);
    int mid=(l+r)>>1;
    update(node<<1,l,mid,u,v,t);
    update(node<<1|1,mid+1,r,u,v,t);
    st[node]=st[node<<1]+st[node<<1|1];
}
void dfs(int node, int l, int r){
    if (l==r){
        res[l]=st[node].l;
        return;
    }
    down(node,l,r);
    int mid=(l+r)>>1;
    dfs(node<<1,l,mid);
    dfs(node<<1|1,mid+1,r);
}
void buildWall(int n, int k, int op[], int left[], int right[], int height[], int finalHeight[]){
    for (int i=0;i<=n*4;i++)
        lazy[i]={0,100000};
    for (int i=0;i<k;i++){
        T t;
        if (op[i]==1)
            t={height[i],100000};
        else
            t={0,height[i]};
        update(1,0,n-1,left[i],right[i],t);
    }
    dfs(1,0,n-1);
    for (int i=0;i<n;i++)
        finalHeight[i]=res[i];
    return;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2652 KB Output is correct
2 Correct 2 ms 2396 KB Output is correct
3 Correct 2 ms 2552 KB Output is correct
4 Correct 5 ms 2908 KB Output is correct
5 Correct 5 ms 3024 KB Output is correct
6 Correct 5 ms 2944 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 106 ms 15928 KB Output is correct
3 Correct 167 ms 12372 KB Output is correct
4 Correct 477 ms 28720 KB Output is correct
5 Correct 309 ms 29788 KB Output is correct
6 Correct 279 ms 28152 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 2 ms 2624 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 5 ms 2944 KB Output is correct
5 Correct 5 ms 2908 KB Output is correct
6 Correct 5 ms 2952 KB Output is correct
7 Correct 0 ms 2396 KB Output is correct
8 Correct 103 ms 16024 KB Output is correct
9 Correct 164 ms 12044 KB Output is correct
10 Correct 487 ms 28904 KB Output is correct
11 Correct 283 ms 29948 KB Output is correct
12 Correct 280 ms 28444 KB Output is correct
13 Correct 1 ms 2396 KB Output is correct
14 Correct 104 ms 16036 KB Output is correct
15 Correct 26 ms 4232 KB Output is correct
16 Correct 500 ms 29264 KB Output is correct
17 Correct 280 ms 28496 KB Output is correct
18 Correct 285 ms 28396 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 2 ms 2396 KB Output is correct
3 Correct 2 ms 2396 KB Output is correct
4 Correct 5 ms 2908 KB Output is correct
5 Correct 5 ms 2908 KB Output is correct
6 Correct 5 ms 2908 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 104 ms 16076 KB Output is correct
9 Correct 166 ms 12112 KB Output is correct
10 Correct 480 ms 28756 KB Output is correct
11 Correct 288 ms 29780 KB Output is correct
12 Correct 276 ms 28380 KB Output is correct
13 Correct 1 ms 2396 KB Output is correct
14 Correct 105 ms 16024 KB Output is correct
15 Correct 27 ms 4188 KB Output is correct
16 Correct 484 ms 29400 KB Output is correct
17 Correct 283 ms 28504 KB Output is correct
18 Correct 288 ms 28780 KB Output is correct
19 Correct 678 ms 140176 KB Output is correct
20 Correct 674 ms 137564 KB Output is correct
21 Correct 697 ms 140032 KB Output is correct
22 Correct 666 ms 137560 KB Output is correct
23 Correct 668 ms 137544 KB Output is correct
24 Correct 671 ms 137576 KB Output is correct
25 Correct 667 ms 137412 KB Output is correct
26 Correct 720 ms 139756 KB Output is correct
27 Correct 685 ms 140112 KB Output is correct
28 Correct 671 ms 137792 KB Output is correct
29 Correct 666 ms 137448 KB Output is correct
30 Correct 665 ms 137424 KB Output is correct