Submission #892900

# Submission time Handle Problem Language Result Execution time Memory
892900 2023-12-26T06:48:11 Z Mr_Husanboy Wall (IOI14_wall) C++17
100 / 100
818 ms 78936 KB
#include "wall.h"
#include <bits/stdc++.h>

using namespace std;
const int inf = 1e9;



struct Segtree{
  struct Node{
    int mn = inf, mx = 0;
    void apply(int x, int type){
      if(type == 1){
        mn = max(mn, x);
        mx = max(mx, x);
      }else{
        mn = min(mn, x);
        mx = min(mx, x);
      }
    }
    void calibrate(){
      mn = inf, mx = 0;
    }
  };
  vector<Node> t;
  int n;

  void init(int _n){
    n = _n;
    t.resize(4 * n);
  }

  void push(int x){
    t[x * 2].apply(t[x].mx, 1);
    t[x * 2].apply(t[x].mn, 2);
    t[x * 2 + 1].apply(t[x].mx, 1);
    t[x * 2 + 1].apply(t[x].mn, 2);
    t[x].calibrate();
  }

  void upd(int x, int l, int r, int ql, int qr, int val, int type){
    if(l > qr || ql > r) return;
    if(ql <= l && r <= qr){
      t[x].apply(val, type);
      return;
    } 
    push(x);
    int m = (l + r) / 2;
    upd(x * 2, l, m, ql, qr, val, type);
    upd(x * 2 + 1, m + 1, r, ql, qr, val, type);
  }

  int get(int x, int l, int r, int ind){
    if(l == r){
      return t[x].mx;
    }
    push(x);
    int m = (l + r) / 2;
    if(ind <= m) return get(x * 2, l, m, ind);
    else return get(x * 2 + 1, m + 1, r, ind);
  }

  //interface

  void upd(int l, int r, int val, int type){
    upd(1, 0, n - 1, l, r, val, type);
  }

  int get(int ind){
    return get(1, 0, n - 1, ind);
  }
};

void buildWall(int n, int k, int op[], int left[], int right[], int height[], int ans[]){
    Segtree t;
    t.init(n);
    for(int i = 0; i < k; i ++){
      t.upd(left[i], right[i], height[i], op[i]);
    }
    for(int i = 0; i < n; i ++) ans[i] = t.get(i);
}

# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 5 ms 860 KB Output is correct
5 Correct 4 ms 860 KB Output is correct
6 Correct 5 ms 860 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 95 ms 8220 KB Output is correct
3 Correct 127 ms 4316 KB Output is correct
4 Correct 349 ms 11716 KB Output is correct
5 Correct 226 ms 11912 KB Output is correct
6 Correct 215 ms 11600 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 5 ms 860 KB Output is correct
5 Correct 4 ms 860 KB Output is correct
6 Correct 5 ms 860 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 96 ms 8204 KB Output is correct
9 Correct 120 ms 4308 KB Output is correct
10 Correct 349 ms 11656 KB Output is correct
11 Correct 232 ms 11860 KB Output is correct
12 Correct 224 ms 11600 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 101 ms 8016 KB Output is correct
15 Correct 21 ms 1372 KB Output is correct
16 Correct 346 ms 11656 KB Output is correct
17 Correct 221 ms 11604 KB Output is correct
18 Correct 220 ms 11856 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 1 ms 500 KB Output is correct
4 Correct 5 ms 860 KB Output is correct
5 Correct 4 ms 860 KB Output is correct
6 Correct 5 ms 860 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 98 ms 8432 KB Output is correct
9 Correct 124 ms 4312 KB Output is correct
10 Correct 339 ms 11572 KB Output is correct
11 Correct 219 ms 11656 KB Output is correct
12 Correct 215 ms 11716 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 99 ms 8064 KB Output is correct
15 Correct 21 ms 1372 KB Output is correct
16 Correct 353 ms 11712 KB Output is correct
17 Correct 219 ms 11656 KB Output is correct
18 Correct 235 ms 11652 KB Output is correct
19 Correct 757 ms 78576 KB Output is correct
20 Correct 747 ms 78476 KB Output is correct
21 Correct 755 ms 78704 KB Output is correct
22 Correct 756 ms 78936 KB Output is correct
23 Correct 752 ms 78672 KB Output is correct
24 Correct 756 ms 78572 KB Output is correct
25 Correct 756 ms 78676 KB Output is correct
26 Correct 818 ms 78668 KB Output is correct
27 Correct 777 ms 78828 KB Output is correct
28 Correct 769 ms 78580 KB Output is correct
29 Correct 762 ms 78748 KB Output is correct
30 Correct 753 ms 78508 KB Output is correct