# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
529933 | Evang | 벽 (IOI14_wall) | C++17 | 0 ms | 0 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/extc++.h>
using namespace std;
using namespace __gnu_pbds;
#ifdef _DEBUG
#define dout(x) clog << "Line " << __LINE__ << ": " << #x << "=" << (x) << el
#else
#define dout(x)
#endif
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define uid(a,b) uniform_int_distribution<int>(a,b)(rng)
#define ins insert
#define ssize(x) (int((x).size()))
#define bs(args...) binary_search(args)
#define lb(args...) lower_bound(args)
#define ub(args...) upper_bound(args)
#define all(x) (x).begin(),(x).end()
#define mp(a, b) make_pair(a, b)
#define mt(args...) make_tuple(args)
#define pb(x) push_back(x)
#define eb(args...) emplace_back(args)
#define ff first
#define ss second
#define die exit(0)
template<typename T>
using vc = vector<T>;
template<typename T>
using uset = unordered_set<T>;
template<typename A, typename B>
using umap = unordered_map<A, B>;
template<typename T, typename Comp>
using pq = std::priority_queue<T, vc<T>, Comp>;
template<typename T>
using maxpq = pq<T, less<T>>;
template<typename T>
using minpq = pq<T, greater<T>>;
template<typename T>
using oset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
using db = double;
using ld = long double;
using ll = long long;
using ull = unsigned long long;
using pi = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vc<int>;
using vll = vc<ll>;
using vpi = vc<pi>;
using vpll = vc<pll>;
using str = string;
constexpr char el = '\n';
constexpr char sp = ' ';
constexpr int inf = 0x3f3f3f3f;
constexpr ll llinf = 0x3f3f3f3f3f3f3f3fLL;
// ---------------------------------------------------------------------
const int N = 8e6+5;
int n, n2, q;
struct node {
int min = 0, max = inf; // min is the minimum value needed to be
} tr[N];
void push(int i){
if(i >= n)
return;
if(tr[i].min){
tr[2*i].min = max(tr[2*i].min, tr[i].min);
tr[2*i].max = max(tr[2*i].max, tr[i].min);
// if(tr[2*i].max < tr[i].min){
// tr[2*i].max = inf;
// tr[2*i].min = tr[i].min;
// }else
// tr[2*i].min = max(tr[2*i].min, tr[i].min);
tr[2*i+1].min = max(tr[2*i+1].min, tr[i].min);
tr[2*i+1].max = max(tr[2*i+1].max, tr[i].min);
// if(tr[2*i+1].max < tr[i].min){
// tr[2*i+1].max = inf;
// tr[2*i+1].min = tr[i].min;
// }else
// tr[2*i+1].min = max(tr[2*i+1].min, tr[i].min);
tr[i].min = 0;
}
if(tr[i].max!=inf){
tr[2*i].max = min(tr[2*i].max, tr[i].max);
tr[2*i].min = min(tr[2*i].min, tr[i].max);
// if(tr[2*i].min>tr[i].max){
// tr[2*i].min = 0;
// tr[2*i].max = tr[i].max;
// }else
// tr[2*i].
tr[2*i+1].max = min(tr[2*i+1].max, tr[i].max);
tr[2*i+1].min = min(tr[2*i+1].min, tr[i].max);
tr[i].max = inf;
}
}
void upd_min(int l, int r, int i, int il, int ir, int x){
if(ir < l || r < il)
return;
if(l <= il && ir <= r){
tr[i].min = max(tr[i].min, x);
tr[i].max = max(tr[i].max, x);
return;
}
push(i);
int im = (il+ir)/2;
upd_min(l, r, 2*i, il, im, x);
upd_min(l, r, 2*i+1, im+1, ir, x);
}
void upd_max(int l, int r, int i, int il, int ir, int x){
if(ir < l || r < il)
return;
if(l <= il && ir <= r){
tr[i].max = min(tr[i].max, x);
tr[i].min = min(tr[i].min, x);
return;
}
push(i);
int im = (il+ir)/2;
upd_max(l, r, 2*i, il, im, x);
upd_max(l, r, 2*i+1, im+1, ir, x);
}
int at(int i){
i += n;
int ans = 0;
while(i>0){
ans = max(ans, tr[i].min);
ans = min(ans, tr[i].max);
i /= 2;
}
return ans;
}
signed main() {
ios::sync_with_stdio(0); cin.tie(0);
cout << fixed; clog << fixed; clog << unitbuf;
#ifdef _DEBUG
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
freopen("debug.txt", "w", stderr);
#else
//freopen(".in", "r", stdin);
//freopen(".out", "w", stdout);
#endif
cin >> n2 >> q;
n = 1;
while(n<n2)
n *= 2;
while(q--){
int t, l, r, h;
cin >> t >> l >> r >> h;
if(t==1)
upd_min(l, r, 1, 0, n-1, h);
else
upd_max(l, r, 1, 0, n-1, h);
}
for(int i = 0; i < n2; ++i)
cout << at(i) << sp;
}