이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
/*
/^--^\
\____/
/ \ _____ _ __ __ ____ _ ____ ____ _____
| || ()_)| |\ \/ /| ===|| |__ / (__` / () \|_ _|
\__ __/ |_| |_|/_/\_\|____||____|\____)/__/\__\ |_|
|^|^\ \^|^|^|^|^|^|^|^|^|^|^|^|^|^|^|^|^|^|^|^|^|^|^|^|^|
| | |\ \| | | | | | | | | | | | | | | | | | | | | | | | |
#####/ /#################################################
| | |\/ | | | | | | | | | | | | | | | | | | | | | | | | |
|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|*/
#pragma GCC optimize("O4,unroll-loops,no-stack-protector")
#include <bits/stdc++.h>
#include <wall.h>
using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<ll,ll>;
//#define int ll //__int128
#define double long double
#define For(i,a,b) for(int i=a;i<=b;i++)
#define Forr(i,a,b) for(int i=a;i>=b;i--)
#define F first
#define S second
#define L(id) (id*2+1)
#define R(id) (id*2+2)
#define LO(x) (x&(-x))
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define sz(x) ((int)x.size())
#define mkp make_pair
#define MOD (ll)(1000000007)
#define INF (ll)(1e17)
#define EPS (1e-9)
#ifdef LOCALMEOW
#define debug(...) do{\
cerr << __LINE__ <<\
" : ("#__VA_ARGS__ << ") = ";\
_OUT(__VA_ARGS__);\
}while(0)
template<typename T> void _OUT(T x) { cerr << x << "\n"; }
template<typename T,typename...I>
void _OUT(T x,I ...tail) { cerr << x << ", "; _OUT(tail...); }
#else
#define debug(...)
#endif
inline void NYA(){ ios::sync_with_stdio(false); cin.tie(0); }
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
int gcd(int a,int b) { return b==0?a:gcd(b,a%b); }
int lcm(int a,int b) { return a/gcd(a,b)*b; }
int fpow(int b,int p){
int ans=1,now=b;
while(p){
if(p&1) ans=ans*now%MOD;
p/=2; now=now*now%MOD;
}
return ans;
}
void minify(int &a,const int &b) { if(b<a) a=b; }
void maxify(int &a,const int &b) { if(b>a) a=b; }
struct SegTree{
int lo[8000080];
int hi[8000080];
#define tag(a,b,c) a=min(max(a,b),c)
void push(int id){
if(lo[id]==-INF && hi[id]==INF) return;
tag(lo[L(id)],lo[id],hi[id]);
tag(hi[L(id)],lo[id],hi[id]);
tag(lo[R(id)],lo[id],hi[id]);
tag(hi[R(id)],lo[id],hi[id]);
lo[id]=-INF; hi[id]=INF;
}
void build(int id,int l,int r){
if(l==r){
lo[id]=hi[id]=0;
return;
}
lo[id]=-INF;
hi[id]=INF;
int m=(l+r)/2;
build(L(id),l,m);
build(R(id),m+1,r);
}
void updhi(int id,int l,int r,int L,int R,int x){
if(l>R || r<L) return;
if(l>=L && r<=R){
minify(hi[id],x);
minify(lo[id],x);
return;
}
int m=(l+r)/2;
push(id);
updhi(L(id),l,m,L,R,x);
updhi(R(id),m+1,r,L,R,x);
}
void updlo(int id,int l,int r,int L,int R,int x){
if(l>R || r<L) return;
if(l>=L && r<=R){
maxify(hi[id],x);
maxify(lo[id],x);
return;
}
int m=(l+r)/2;
push(id);
updlo(L(id),l,m,L,R,x);
updlo(R(id),m+1,r,L,R,x);
}
void ask(int id,int l,int r,int ans[]){
if(l==r){
ans[l]=lo[id];
return;
}
int m=(l+r)/2;
push(id);
ask(L(id),l,m,ans);
ask(R(id),m+1,r,ans);
}
}seg;
void buildWall(int n,int q,int op[],int l[],int r[],int h[], int final[]){
seg.build(0,0,n-1);
For(i,0,q-1){
if(op[i]==1) seg.updlo(0,0,n-1,l[i],r[i],h[i]);
else seg.updhi(0,0,n-1,l[i],r[i],h[i]);
}
seg.ask(0,0,n-1,final);
}
#ifdef LOCALMEOW
int32_t main(){
//shinon >//////<
int n=10,q=6;
int op[6]={1,2,2,1,1,2};
int l[6]={1,4,3,0,2,6};
int r[6]={8,9,6,5,2,7};
int h[6]={4,1,5,3,5,0};
int fin[10];
buildWall(n,q,op,l,r,h,fin);
For(i,0,9) cout<<fin[i]<<"\n";
}
#endif
컴파일 시 표준 에러 (stderr) 메시지
wall.cpp: In member function 'void SegTree::push(int)':
wall.cpp:77:10: warning: overflow in conversion from 'll' {aka 'long long int'} to 'int' changes value from '-100000000000000000' to '-1569325056' [-Woverflow]
77 | lo[id]=-INF; hi[id]=INF;
| ^
wall.cpp:36:13: warning: overflow in conversion from 'll' {aka 'long long int'} to 'int' changes value from '100000000000000000' to '1569325056' [-Woverflow]
36 | #define INF (ll)(1e17)
| ^~~~~~~~~~
wall.cpp:77:23: note: in expansion of macro 'INF'
77 | lo[id]=-INF; hi[id]=INF;
| ^~~
wall.cpp: In member function 'void SegTree::build(int, int, int)':
wall.cpp:84:10: warning: overflow in conversion from 'll' {aka 'long long int'} to 'int' changes value from '-100000000000000000' to '-1569325056' [-Woverflow]
84 | lo[id]=-INF;
| ^
wall.cpp:36:13: warning: overflow in conversion from 'll' {aka 'long long int'} to 'int' changes value from '100000000000000000' to '1569325056' [-Woverflow]
36 | #define INF (ll)(1e17)
| ^~~~~~~~~~
wall.cpp:85:10: note: in expansion of macro 'INF'
85 | hi[id]=INF;
| ^~~
# | 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... |