#include <bits/stdc++.h>
#define ios ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define file(s) if (fopen(s".in", "r")) freopen(s".in", "r", stdin), freopen(s".out", "w", stdout)
#define aint(a) a.begin() , a.end()
#define F first
#define S second
using namespace std;
using ll = long long;
const int N = 300005 , inf = 2e9 + 7;
const ll INF = 1e18 , mod = 1e9+7 , P = 6547;
int n , q;
vector<pair<int,int>> v[N];
int t[N*4] , u[N*4];
void push(int v , int tl , int tr){
if(tl == tr || u[v] == 0) return;
t[v*2] += u[v];
t[v*2+1] += u[v];
u[v*2] += u[v];
u[v*2+1] += u[v];
u[v] = 0;
}
void upd(int v , int tl , int tr , int pos , int val){
push(v,tl,tr);
if(tl == tr){
t[v] = val;
return;
}
int tm = (tl+tr) >> 1;
if(pos <= tm) upd(v*2,tl,tm,pos,val);
else upd(v*2+1,tm+1,tr,pos,val);
t[v] = max(t[v*2] , t[v*2+1]);
}
void solve(){
cin >> n >> q;
while(q--){
int l , r , x;
cin >> l >> r >> x;
v[l].push_back({1 , x});
v[r+1].push_back({0 , l});
}
u[1] = -inf;
t[1] = -inf;
for(int i = 1; i <= n; i++){
sort(aint(v[i]));
for(pair<int,int> x : v[i]){
if(x.F == 1) upd(1,1,n,i,x.S);
else upd(1,1,n,x.S,-inf);
}
cout << max(t[1] , 0) <<" ";
t[1]++;
u[1]++;
}
}
/*
*/
signed main(){
ios;
file("trading");
solve();
return 0;
}
Compilation message
trading.cpp: In function 'int main()':
trading.cpp:4:48: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
4 | #define file(s) if (fopen(s".in", "r")) freopen(s".in", "r", stdin), freopen(s".out", "w", stdout)
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~
trading.cpp:64:2: note: in expansion of macro 'file'
64 | file("trading");
| ^~~~
trading.cpp:4:77: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
4 | #define file(s) if (fopen(s".in", "r")) freopen(s".in", "r", stdin), freopen(s".out", "w", stdout)
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
trading.cpp:64:2: note: in expansion of macro 'file'
64 | file("trading");
| ^~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
7328 KB |
Output is correct |
2 |
Correct |
5 ms |
7272 KB |
Output is correct |
3 |
Incorrect |
4 ms |
7380 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |