Submission #1043517

# Submission time Handle Problem Language Result Execution time Memory
1043517 2024-08-04T10:32:23 Z mindiyak Wall (IOI14_wall) C++14
24 / 100
193 ms 12416 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<ld, ld> pd;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<vector<int>> vvi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
#define FOR(i, a, b) for (ll i = a; i < (b); i++)
#define F0R(i, a) for (ll i = 0; i < (a); i++)
#define FORd(i, a, b) for (ll i = (b)-1; i >= a; i--)
#define F0Rd(i, a) for (ll i = (a)-1; i >= 0; i--)
#define trav(a, x) for (auto &a : x)
#define uid(a, b) uniform_int_distribution<int>(a, b)(rng)
#define len(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fst first
#define nl endl
#define sec second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define ins insert
const int MOD = 1000000007;
const int MX = INT_MAX;
const int MN = INT_MIN;

#include "wall.h"

vi seg1,seg2;

void update(int pos,int l,int r,int ql,int qr,int val,int type){
  if(ql>r||qr<l)return;
  if(ql<=l && r<=qr){
    if(type == 1){
      seg1[pos] = max(seg1[pos],val);
    }else{
      seg2[pos] = min(seg2[pos],val);
    }
    return;
  }
  int mid = (l+r)/2;
  update(2*pos+1,l,mid,ql,qr,val,type);
  update(2*pos+2,mid+1,r,ql,qr,val,type);
}

int get(int pos,int l,int r,int index,int val,int type){
  if(l == r){
    if(type == 1){
      return max(val,seg1[pos]);
    }else{
      return min(val,seg2[pos]);
    }
  }
  int mid = (l+r)/2;

  if(type == 1){
    val = max(val,seg1[pos]);
  }else{
    val = min(val,seg2[pos]);
  }

  if(index <= mid)
    return get(2*pos+1,l,mid,index,val,type);
  else 
    return get(2*pos+2,mid+1,r,index,val,type);
}


void buildWall(int n, int k, int op[], int left[], int right[], int height[], int finalHeight[]){
  FOR(i,0,n)finalHeight[i] = 0;

  seg1 = vi(4*n + 5,0);
  seg2 = vi(4*n + 5,2e9);

  FOR(i,0,k){
    update(0,0,n-1,left[i],right[i],height[i],op[i]);
    
    // FOR(j,0,n){
    //   finalHeight[j] = get(0,0,n-1,j,0,1);
    //   finalHeight[j] = min(get(0,0,n-1,j,2e9,2),finalHeight[j]);
    //   cout << finalHeight[j] << " ";
    // }cout << endl;

  }

  FOR(j,0,n){
    finalHeight[j] = get(0,0,n-1,j,0,1);
    finalHeight[j] = min(get(0,0,n-1,j,2e9,2),finalHeight[j]);
    // cout << finalHeight[j] << " ";
  }
  // cout << endl;
}

# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 2 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 69 ms 8188 KB Output is correct
3 Correct 84 ms 4316 KB Output is correct
4 Correct 193 ms 11860 KB Output is correct
5 Correct 123 ms 12416 KB Output is correct
6 Correct 175 ms 12376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Incorrect 1 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 1 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -