제출 #672186

#제출 시각아이디문제언어결과실행 시간메모리
672186Alihan_8거래 (IZhO13_trading)C++17
0 / 100
8 ms19080 KiB
#include <bits/stdc++.h> // include <ext/pb_ds/assoc_container.hpp> // include <ext/pb_ds/tree_policy.hpp> // using namespace __gnu_pbds; using namespace std; #define all(x) x.begin(), x.end() #define pb push_back // define ordered_set tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update> #define mpr make_pair #define ln '\n' void IO(string name){freopen((name+".in").c_str(),"r",stdin); freopen((name+".out").c_str(),"w",stdout);} #define int long long const int N = 3e5+1; struct segTree{ int l, val; segTree(int l, int val) : l(l), val(val) {} segTree() : segTree(0, 0) {} }; segTree lazy[N*4]; int T[N*4]; void push(int v, int l, int r){ if ( !lazy[v].val ) return; if ( l != r ) lazy[v*2] = lazy[v*2+1] = lazy[v]; T[v] = max(T[v], lazy[v].val+l-lazy[v].l); lazy[v] = segTree(); } void upd(int v, int l, int r, int tl, int tr, int val){ push(v, l, r); if ( l != r ){ int md = (l+r)>>1; push(v*2, l, md), push(v*2+1, md+1, r); } if ( l > tr or r < tl ) return; if ( tl <= l and tr >= r ){ lazy[v] = segTree(tl, val); push(v, l, r); if ( l != r ){ int md = (l+r)>>1; push(v*2, l, md), push(v*2+1, md+1, r); } return; } int md = (l+r)>>1; upd(v*2, l, md, tl, tr, val), upd(v*2+1, md+1, r, tl, tr, val); T[v] = min(T[v*2], T[v*2+1]); } int get(int v, int l, int r, int pos){ push(v, l, r); if ( l != r ){ int md = (l+r)>>1; push(v*2, l, md), push(v*2+1, md+1, r); } if ( l == r ) return T[v]; int md = (l+r)>>1; if ( pos <= md ) return get(v*2, l, md, pos); return get(v*2+1, md+1, r, pos); } signed main(){ ios_base::sync_with_stdio(false); cin.tie(NULL); int n, q; cin >> n >> q; while ( q-- ){ int l, r, x; cin >> l >> r >> x; upd(1, 1, n, l, r, x); } for ( int i = 1; i <= n; i++ ) cout << get(1, 1, n, i) << ' '; cout << '\n'; }

컴파일 시 표준 에러 (stderr) 메시지

trading.cpp: In function 'void IO(std::string)':
trading.cpp:11:29: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   11 | void IO(string name){freopen((name+".in").c_str(),"r",stdin); freopen((name+".out").c_str(),"w",stdout);}
      |                      ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
trading.cpp:11:70: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   11 | void IO(string name){freopen((name+".in").c_str(),"r",stdin); freopen((name+".out").c_str(),"w",stdout);}
      |                                                               ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...