Submission #1105784

# Submission time Handle Problem Language Result Execution time Memory
1105784 2024-10-27T18:42:21 Z hihihihaw Wall (IOI14_wall) C++17
100 / 100
446 ms 103616 KB
#pragma GCC optimize("O3,unroll-loops")    
#include "wall.h"
#include <bits/stdc++.h>
using namespace std;
 
#define pb push_back
#define pii pair<int,int>
#define sz(v) (int)v.size()
#define fi first
#define se second
#define INF 1223372036854775807
#define MOD  998244353
#define cint(x) int x;cin>>x;
#define cinarr(a,n) int a[n];for (int i=0;i<n;i++) cin>>a[i];
#define coutarr(a) for (auto d:a)cout<<d<<" "; cout<<endl;
#define coutarrD(a) for (auto d:a) cout<<d.fi<<","<<d.se<<" "; cout<<endl;
#define BERKAY_TUP ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define endl '\n'
#define ld long double
#define mid (start+end)/2
#define vvi vector<vector<int>>
int lazy[8000023][2];
int res[2000023];
void apply(int node,int a,int b){
    if (b<=lazy[node][0]){
        lazy[node][0]=b;
        lazy[node][1]=b;
    }
    else if (a>=lazy[node][1]){
        lazy[node][0]=a;
        lazy[node][1]=a;
    }
    else if (a>=lazy[node][0] && b<=lazy[node][1]){
        lazy[node][0]=a;
        lazy[node][1]=b;
    }
    else{
        lazy[node][0]=max(lazy[node][0],a);
        lazy[node][1]=min(lazy[node][1],b);
    }
}
void push(int node,int start,int end){
    int a=lazy[node][0],b=lazy[node][1];
    //cout<<"pushed "<<node<<" "<<start<<" "<<end<<" "<<a<<" "<<b<<endl;
    apply(node*2,a,b);
    apply(node*2+1,a,b);
    lazy[node][0]=0;
    lazy[node][1]=99999999;
}
void update(int node,int start,int end,int l,int r,int a,int b){
    //cout<<"-  "<<node<<" "<<start<<" "<<end<<endl;
    if (start>end ||start>r || end<l) return;
    if (start>=l && end<=r){
        //cout<<"updated "<<node<<endl;
        //cout<<"with "<<a<<" "<<b<<endl;
        //cout<<lazy[node][0]<<" "<<lazy[node][1]<<endl;
        apply(node,a,b);
        //cout<<lazy[node][0]<<" "<<lazy[node][1]<<endl;
        return;
    }
    push(node,start,end);
    update(node*2,start,mid,l,r,a,b);
    update(node*2+1,mid+1,end,l,r,a,b);
}
void pushAll(int node,int start,int end){
    if (start==end){
        res[start-1]=lazy[node][0];
        return;
    }
    push(node,start,end);
    pushAll(node*2,start,mid);
    pushAll(node*2+1,mid+1,end);
}
void buildWall(int n, int k, int op[], int left[], int right[], int height[], int finalHeight[]){
    for (int i=1;i<4*n+10;i++){
        lazy[i][0]=0;
        lazy[i][1]=99999999;
    }
    for (int i=0;i<k;i++){
        int a=0,b=999999999;
        if (op[i]==1) a=height[i];
        else b=height[i];
        update(1,1,n,left[i]+1,right[i]+1,a,b);
    }
    //cout<<"---"<<endl;
    pushAll(1,1,n);
    for (int i=0;i<n;i++) finalHeight[i]=res[i];
    return;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2384 KB Output is correct
2 Correct 2 ms 2384 KB Output is correct
3 Correct 2 ms 2384 KB Output is correct
4 Correct 5 ms 2640 KB Output is correct
5 Correct 5 ms 2640 KB Output is correct
6 Correct 4 ms 2764 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2384 KB Output is correct
2 Correct 90 ms 14408 KB Output is correct
3 Correct 138 ms 9316 KB Output is correct
4 Correct 395 ms 21320 KB Output is correct
5 Correct 195 ms 25672 KB Output is correct
6 Correct 187 ms 22344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2384 KB Output is correct
2 Correct 2 ms 2384 KB Output is correct
3 Correct 2 ms 2384 KB Output is correct
4 Correct 5 ms 2640 KB Output is correct
5 Correct 4 ms 2640 KB Output is correct
6 Correct 4 ms 2640 KB Output is correct
7 Correct 1 ms 2384 KB Output is correct
8 Correct 83 ms 13232 KB Output is correct
9 Correct 141 ms 11128 KB Output is correct
10 Correct 374 ms 26852 KB Output is correct
11 Correct 182 ms 23112 KB Output is correct
12 Correct 195 ms 22300 KB Output is correct
13 Correct 1 ms 2384 KB Output is correct
14 Correct 87 ms 16020 KB Output is correct
15 Correct 23 ms 3728 KB Output is correct
16 Correct 399 ms 24564 KB Output is correct
17 Correct 193 ms 22344 KB Output is correct
18 Correct 192 ms 26440 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2552 KB Output is correct
2 Correct 2 ms 2640 KB Output is correct
3 Correct 2 ms 2384 KB Output is correct
4 Correct 5 ms 2764 KB Output is correct
5 Correct 4 ms 2640 KB Output is correct
6 Correct 4 ms 2640 KB Output is correct
7 Correct 1 ms 2384 KB Output is correct
8 Correct 89 ms 15172 KB Output is correct
9 Correct 130 ms 10008 KB Output is correct
10 Correct 377 ms 18800 KB Output is correct
11 Correct 203 ms 25596 KB Output is correct
12 Correct 186 ms 24416 KB Output is correct
13 Correct 1 ms 2384 KB Output is correct
14 Correct 88 ms 10312 KB Output is correct
15 Correct 24 ms 3664 KB Output is correct
16 Correct 434 ms 26440 KB Output is correct
17 Correct 209 ms 26440 KB Output is correct
18 Correct 207 ms 24648 KB Output is correct
19 Correct 430 ms 96840 KB Output is correct
20 Correct 427 ms 103616 KB Output is correct
21 Correct 446 ms 102216 KB Output is correct
22 Correct 438 ms 94236 KB Output is correct
23 Correct 412 ms 102332 KB Output is correct
24 Correct 406 ms 102508 KB Output is correct
25 Correct 414 ms 95048 KB Output is correct
26 Correct 424 ms 96840 KB Output is correct
27 Correct 422 ms 96808 KB Output is correct
28 Correct 422 ms 102472 KB Output is correct
29 Correct 424 ms 99660 KB Output is correct
30 Correct 441 ms 102296 KB Output is correct