# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
471388 | MohamedFaresNebili | 벽 (IOI14_wall) | C++14 | 0 ms | 0 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include "wall.h"
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<long long>;
#define mp make_pair
#define pb push_back
#define pp pop_back
#define ff first
#define ss second
#define lb lower_bound
#define ub upper_bound
#define all(x) (x).begin() , (x).end()
const int N = 2*100005;
const long long MOD = 1e9+7;
const long double EPS = 0.000000001;
const double PI = 3.14159265358979323846;
const int nx[4]={1, -1, 0, 0}, ny[4]={0, 0, 1, -1};
long long gcd(int a, int b) { return (b==0?a:gcd(b, a%b)); }
long long lcm(int a, int b) { return a*(b/gcd(a, b)); }
long long fact(int a) { return (a==1?1:a*fact(a-1)); }
int st[4*200005], lazy[4*200005], p[4*200005];
void prop(int v, int l, int r) {
if(l==r||p[v]==-1) return;
if(p[v]==1) {
st[v*2]=max(st[v*2], lazy[v]);
st[v*2+1]=max(st[v*2+1], lazy[v]);
lazy[v*2]=max(lazy[v*2], lazy[v]);
lazy[v*2]=max(lazy[v*2+1], lazy[v]);
}
else if(p[v]==2) {
st[v*2]=min(st[v*2], lazy[v]);
st[v*2+1]=min(st[v*2+1], lazy[v]);
lazy[v*2]=min(lazy[v*2], lazy[v]);
lazy[v*2]=min(lazy[v*2+1], lazy[v]);
}
p[v*2]=p[v*2+1]=p[v]; p[v]=-1;
}
void update0(int v, int l, int r, int lo, int hi, int val) {
prop(v, l, r);
if(l>hi||r<lo) return;
if(l>=lo&&r<=hi) {
lazy[v]=max(lazy[v], val); p[v]=1;
st[v]=max(st[v], val); prop(v, l, r);
return;
}
update0(v*2, l, (l+r)/2, lo, hi, val);
update0(v*2+1, (l+r)/2+1, r, lo, hi, val);
}
void update(int v, int l, int r, int lo, int hi, int val) {
prop(v, l, r);
if(l>hi||r<lo) return;
if(l>=lo&&r<=hi) {
lazy[v]=min(lazy[v], val); p[v]=2;
st[v]=min(st[v], val); prop(v, l, r);
return;
}
update(v*2, l, (l+r)/2, lo, hi, val);
update(v*2+1, (l+r)/2+1, r, lo, hi, val);
}
ll query(int v, int l, int r, int ind) {
prop(v, l, r);
if(l==r) return st[v];
int mid=(l+r)/2;
if(ind<=mid) return query(v*2, l, mid, ind);
else return query(v*2+1, mid+1, r, ind);
}