이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "wall.h"
#include <bits/stdc++.h>
using namespace std;
const int mxN = (int)2e5+10;
int n, k, a[mxN];
array<int,2> seg[mxN*2];
void prop(int p, int l, int r){
if(l==r) return; return;
int mid = (l+r)/2; int rp = p+2*(mid-l+1);
for(int i : {0,1}){
seg[p+1][i]=seg[p][i];
seg[rp][i]=seg[p][i];
}
}
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){
if(t==1){
//if(seg[p][0]>=v) return;
if(seg[p][1]<=v and l==r){ seg[p][0]=seg[p][1]=v; return; }
if(l!=r) upd(i,j,t,v,p+1,l,mid), upd(i,j,t,v,rp,mid+1,r);
}
else{
//if(seg[p][1]<=v) return;
if(seg[p][0]>=v and l==r) {seg[p][0]=seg[p][1]=v; return; }
if(l!=r) upd(i,j,t,v,p+1,l,mid), upd(i,j,t,v,rp,mid+1,r);
}
return;
}
upd(i,j,t,v,p+1,l,mid), upd(i,j,t,v,rp,mid+1,r);
seg[p] = {min(seg[p+1][0],seg[rp][0]), max(seg[p+1][1],seg[rp][1])};
}
void query(int p=0, int l=0, int r=n-1){
if(l==r){ a[l]=seg[p][0]; 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 < k; i++) upd(l[i],r[i],o[i],h[i]);
query(); for(int i = 0; i < n; i++) ans[i]=a[i];
}
컴파일 시 표준 에러 (stderr) 메시지
wall.cpp: In function 'void prop(int, int, int)':
wall.cpp:9:5: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
9 | if(l==r) return; return;
| ^~
wall.cpp:9:22: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
9 | if(l==r) return; return;
| ^~~~~~
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);
| ^~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |