답안 #742515

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
742515 2023-05-16T11:15:36 Z Cookie 벽 (IOI14_wall) C++14
100 / 100
920 ms 91496 KB
#include<bits/stdc++.h>
#include<fstream>
using namespace std;
ifstream fin("VNOICUP.INP");
ofstream fout("VNOICUP.OUT");
#define sz(a) (int)a.size()
#define ll long long
#define pb push_back
#define forr(i, a, b) for(int i = a; i < b; i++)
#define dorr(i, a, b) for(int i = a; i >= b; i--)
#define ld long double
#define vt vector
#include<fstream>
#define fi first
#define se second
#define pll pair<ll, ll>
#define pii pair<int, int>
const ld PI = 3.14159265359;
const int X[4] = {1, -1, 0, 0};
const int Y[4] = {0, 0, 1, -1};
const ll mod = 1e9 + 7;
const int mxn = 2e6 + 5, mxm = 1e5, sq = 400;
const int base = (1 << 18);
const ll inf = 1e9;
#include "wall.h"
int mx[4 * mxn + 1], mn[4 * mxn + 1]; 
void push(int nd){
    mn[nd << 1] = min(mn[nd << 1], mn[nd]); mx[nd << 1] = min(mn[nd << 1], mx[nd << 1]);
    mx[nd << 1] = max(mx[nd], mx[nd << 1]); mn[nd << 1] = max(mn[nd << 1], mx[nd << 1]);
    mn[nd << 1 | 1] = min(mn[nd << 1 | 1], mn[nd]); mx[nd << 1 | 1] = min(mn[nd << 1 | 1], mx[nd << 1 | 1]);
    mx[nd << 1 | 1] = max(mx[nd], mx[nd << 1 | 1]); mn[nd << 1 | 1] = max(mx[nd << 1 | 1], mn[nd << 1 | 1]);
    mx[nd] = 0; mn[nd] = 1e9 + 1;
}
void add(int nd, int l, int r, int ql, int qr, int v){
    if(ql > r || qr < l)return;
    if(ql <= l && qr >= r){
        
        mx[nd] = max(mx[nd], v); mn[nd] = max(mn[nd], mx[nd]);
        return;
    }
    int mid = (l + r) >> 1;
    push(nd);
    add(nd << 1, l, mid, ql, qr, v);
    add(nd << 1 | 1, mid + 1, r, ql, qr, v);
}
void rem(int nd, int l, int r, int ql, int qr, int v){
   
    if(ql > r || qr < l)return;
    if(ql <= l && qr >= r){
        
        mn[nd] = min(mn[nd], v); mx[nd] = min(mx[nd], mn[nd]);
        return;
    }
    int mid = (l + r) >> 1;
    push(nd);
    rem(nd << 1, l, mid, ql, qr, v);
    rem(nd << 1 | 1, mid + 1, r, ql, qr, v);
}
int get(int nd, int l, int r, int id){
    if(l == r){
        return(min(mn[nd], mx[nd]));
    }
    push(nd);
    int mid = (l + r) >> 1;
    if(id <= mid){
        return(get(nd << 1, l, mid, id));
    }else{
        return(get(nd << 1 | 1, mid + 1, r, id));
    }
}
void buildWall(int n, int k, int op[], int left[], int right[], int height[], int finalHeight[]){
   for(int i = 1; i <= 4 * n; i++){
       mx[i] = 0; mn[i] = 1e9 + 1;
   }
   forr(i, 0, k){
       if(op[i] == 1)add(1, 0, n - 1, left[i], right[i], height[i]);
       else rem(1, 0, n - 1, left[i], right[i], height[i]);
   }
   forr(i, 0, n){
       finalHeight[i] = get(1, 0, n - 1, i);
   }
  return;
}

# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 2 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 6 ms 852 KB Output is correct
5 Correct 6 ms 836 KB Output is correct
6 Correct 5 ms 852 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 113 ms 8156 KB Output is correct
3 Correct 123 ms 4192 KB Output is correct
4 Correct 356 ms 14028 KB Output is correct
5 Correct 249 ms 14532 KB Output is correct
6 Correct 247 ms 14788 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 3 ms 340 KB Output is correct
4 Correct 6 ms 836 KB Output is correct
5 Correct 5 ms 852 KB Output is correct
6 Correct 6 ms 852 KB Output is correct
7 Correct 1 ms 320 KB Output is correct
8 Correct 131 ms 10808 KB Output is correct
9 Correct 133 ms 6752 KB Output is correct
10 Correct 367 ms 14064 KB Output is correct
11 Correct 284 ms 14504 KB Output is correct
12 Correct 243 ms 14920 KB Output is correct
13 Correct 1 ms 312 KB Output is correct
14 Correct 145 ms 10796 KB Output is correct
15 Correct 24 ms 2052 KB Output is correct
16 Correct 361 ms 14396 KB Output is correct
17 Correct 254 ms 14408 KB Output is correct
18 Correct 299 ms 14372 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 2 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 5 ms 852 KB Output is correct
5 Correct 5 ms 852 KB Output is correct
6 Correct 7 ms 964 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 127 ms 10672 KB Output is correct
9 Correct 132 ms 6860 KB Output is correct
10 Correct 357 ms 14072 KB Output is correct
11 Correct 266 ms 14536 KB Output is correct
12 Correct 243 ms 14876 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 124 ms 10648 KB Output is correct
15 Correct 23 ms 2040 KB Output is correct
16 Correct 358 ms 14344 KB Output is correct
17 Correct 253 ms 14400 KB Output is correct
18 Correct 248 ms 14396 KB Output is correct
19 Correct 881 ms 91072 KB Output is correct
20 Correct 868 ms 88600 KB Output is correct
21 Correct 871 ms 91156 KB Output is correct
22 Correct 867 ms 88652 KB Output is correct
23 Correct 878 ms 88520 KB Output is correct
24 Correct 858 ms 88604 KB Output is correct
25 Correct 869 ms 88516 KB Output is correct
26 Correct 910 ms 91100 KB Output is correct
27 Correct 920 ms 91496 KB Output is correct
28 Correct 909 ms 89376 KB Output is correct
29 Correct 857 ms 88572 KB Output is correct
30 Correct 866 ms 88508 KB Output is correct