Submission #70866

# Submission time Handle Problem Language Result Execution time Memory
70866 2018-08-23T14:34:30 Z doowey Wall (IOI14_wall) C++14
100 / 100
1092 ms 191700 KB
#include "wall.h"
#include <bits/stdc++.h>

using namespace std;

const int N = 2000101;

struct Node{
  int min_op;
  int max_op;
};

Node Tree[N * 3];

void init(int node, int cl, int cr){
  Tree[node].min_op = (int)1e9 + 9;
  Tree[node].max_op = 0;
  if(cl == cr){
    return;
  }
  int md = (cl + cr)/2;
  init(node * 2, cl, md);
  init(node * 2 + 1, md + 1, cr);

}

void maxi(int node, int x){ // apply max(node)
  Tree[node].max_op = max(Tree[node].max_op, x);
  Tree[node].min_op = max(Tree[node].min_op, Tree[node].max_op);
}

void mini(int node, int x){ // apply min(node)
  Tree[node].min_op = min(Tree[node].min_op, x);
  Tree[node].max_op = min(Tree[node].max_op, Tree[node].min_op);
}

void push(int node, int tl, int tr){
  maxi(node * 2, Tree[node].max_op);
  maxi(node * 2 + 1, Tree[node].max_op);
  mini(node * 2, Tree[node].min_op);
  mini(node * 2 + 1, Tree[node].min_op);
  Tree[node].max_op = 0;
  Tree[node].min_op = (int)1e9 + 9;
}

void update(int node, int cl, int cr, int tl, int tr, int x, int op){
  if(cr < tl)
    return;
  if(cl > tr)
    return;
  if(cl >= tl and cr <= tr){
    if(op == 1)
      maxi(node, x);
    else
      mini(node, x);
    return;
  }
  push(node, cl, cr);
  int md = (cl + cr)/2;
  update(node*2, cl, md, tl, tr, x, op);
  update(node*2+1, md + 1, cr, tl, tr, x, op);
}

int fin[N];

void ff(int node, int cl, int cr){
  if(cl == cr){
    fin[cl] = Tree[node].max_op;
    return;
  }
  push(node, cl, cr);
  int md = (cl + cr)/2;
  ff(node * 2, cl, md);
  ff(node * 2 + 1, md + 1, cr);
}

void buildWall(int n, int k, int op[], int left[], int right[], int height[], int finalHeight[]){
  init(1, 0, n-1);
  for(int i = 0;i < k;i ++ ){
    update(1, 0, n - 1, left[i], right[i], height[i], op[i]);
  }
  ff(1, 0, n - 1);
  for(int i = 0;i < n;i ++ )
    finalHeight[i] = fin[i];
  return;
}

# Verdict Execution time Memory Grader output
1 Correct 3 ms 252 KB Output is correct
2 Correct 5 ms 560 KB Output is correct
3 Correct 5 ms 560 KB Output is correct
4 Correct 10 ms 1040 KB Output is correct
5 Correct 10 ms 1256 KB Output is correct
6 Correct 11 ms 1388 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 1388 KB Output is correct
2 Correct 253 ms 14608 KB Output is correct
3 Correct 303 ms 14608 KB Output is correct
4 Correct 890 ms 31024 KB Output is correct
5 Correct 525 ms 34836 KB Output is correct
6 Correct 396 ms 34836 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 34836 KB Output is correct
2 Correct 6 ms 34836 KB Output is correct
3 Correct 4 ms 34836 KB Output is correct
4 Correct 12 ms 34836 KB Output is correct
5 Correct 9 ms 34836 KB Output is correct
6 Correct 8 ms 34836 KB Output is correct
7 Correct 2 ms 34836 KB Output is correct
8 Correct 231 ms 34836 KB Output is correct
9 Correct 266 ms 34836 KB Output is correct
10 Correct 730 ms 34836 KB Output is correct
11 Correct 456 ms 34836 KB Output is correct
12 Correct 392 ms 34836 KB Output is correct
13 Correct 2 ms 34836 KB Output is correct
14 Correct 283 ms 34836 KB Output is correct
15 Correct 42 ms 34836 KB Output is correct
16 Correct 720 ms 34836 KB Output is correct
17 Correct 473 ms 34836 KB Output is correct
18 Correct 466 ms 34836 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 34836 KB Output is correct
2 Correct 4 ms 34836 KB Output is correct
3 Correct 4 ms 34836 KB Output is correct
4 Correct 13 ms 34836 KB Output is correct
5 Correct 9 ms 34836 KB Output is correct
6 Correct 10 ms 34836 KB Output is correct
7 Correct 2 ms 34836 KB Output is correct
8 Correct 258 ms 34836 KB Output is correct
9 Correct 273 ms 34836 KB Output is correct
10 Correct 815 ms 34836 KB Output is correct
11 Correct 456 ms 34836 KB Output is correct
12 Correct 446 ms 34836 KB Output is correct
13 Correct 2 ms 34836 KB Output is correct
14 Correct 282 ms 34836 KB Output is correct
15 Correct 54 ms 34836 KB Output is correct
16 Correct 676 ms 34836 KB Output is correct
17 Correct 472 ms 34836 KB Output is correct
18 Correct 474 ms 34836 KB Output is correct
19 Correct 996 ms 89760 KB Output is correct
20 Correct 890 ms 89760 KB Output is correct
21 Correct 962 ms 100200 KB Output is correct
22 Correct 960 ms 108256 KB Output is correct
23 Correct 962 ms 118800 KB Output is correct
24 Correct 997 ms 129236 KB Output is correct
25 Correct 1027 ms 139712 KB Output is correct
26 Correct 1014 ms 152624 KB Output is correct
27 Correct 1092 ms 163088 KB Output is correct
28 Correct 1068 ms 171216 KB Output is correct
29 Correct 915 ms 181592 KB Output is correct
30 Correct 944 ms 191700 KB Output is correct