답안 #758406

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
758406 2023-06-14T15:05:40 Z Dan4Life 벽 (IOI14_wall) C++17
0 / 100
137 ms 8176 KB
#include <bits/stdc++.h>
using namespace std;
const int mxN = (int)2e6+10;
int n, k, a[mxN];
array<int,2> seg[mxN*2];
//maximize then minimize
void prop(int p, int l, int r){
    if(l==r) return;
    int mid = (l+r)/2; int rp = p+2*(mid-l+1);
    for(int i : {0,1}){
        seg[p+1][i] = min(max(seg[p+1][i],seg[p][0]),seg[p][1]);
        seg[rp][i] = min(max(seg[rp][i],seg[p][0]),seg[p][1]);
    }
    seg[p] = {0,mxN};
}

void upd(int i, int j, int t, int v, int p=0, int l=0, int r=n-1){
    if(i>r or j<l or i>j) return; prop(p,l,r);
    int mid = (l+r)/2; int rp = p+2*(mid-l+1);
    if(i<=l and r<=j){ seg[p][t]=v; return; }
    upd(i,j,t,v,p+1,l,mid), upd(i,j,t,v,rp,mid+1,r);
}

void query(int p=0, int l=0, int r=n-1){
    if(l==r){ a[l]=min(seg[p][0],seg[p][1]); return; } prop(p,l,r);
    int mid = (l+r)/2; int rp = p+2*(mid-l+1);
    query(p+1,l,mid), query(rp,mid+1,r);
}

void buildWall(int N, int k, int o[], int l[], int r[], int h[], int ans[]){
    n = N;
    for(int i = 0; i <= 2*n; i++) seg[i]={0,mxN};
    for(int i = 0; i < k; i++) upd(l[i],r[i],o[i]-1,h[i]);
    query(); for(int i = 0; i < n; i++) ans[i]=a[i];
}

Compilation message

wall.cpp: In function 'void upd(int, int, int, int, int, int, int)':
wall.cpp:18:5: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
   18 |     if(i>r or j<l or i>j) return; prop(p,l,r);
      |     ^~
wall.cpp:18:35: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
   18 |     if(i>r or j<l or i>j) return; prop(p,l,r);
      |                                   ^~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 2 ms 340 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 137 ms 8176 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 3 ms 340 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 3 ms 340 KB Output isn't correct
3 Halted 0 ms 0 KB -