#include <bits/stdc++.h>
#define fr first
#define sc second
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
int N;
int tree[300005 * 4];
pair<int,int> p[300005 * 4];
int n , m , l , r , x;
void upd( int l , int r , int val , int v = 1 , int tl = 1 , int tr = n )
{
if( tl > r || tr < l )return;
if( l <= tl && tr <= r )
{
tree[v] = max( tree[v] , val + ( tl - l ) );;
return;
}
int mid = (tl + tr) / 2;
upd( l , r , val , v + v , tl , mid );
upd( l , r , val , v+v+1 , mid+1 , tr );
}
void get( int l , int r , int v = 1 , int tl = 1 , int tr = n )
{
// cout << tl << " " << tr << endl;
if( p[v].fr || tree[v] )
{
if( tree[v] )
p[v] = {v , tl};
p[v+v] = p[v+v+1] = p[v];
}
if( tl > r || tr < l )return;
if( l <= tl && tr <= r )
{
if( p[v].fr )
cout << tree[ p[v].fr ] + ( -p[v].sc + tl ) << " ";
else
cout << 0 << " ";
return;
}
int mid = (tl + tr) / 2;
get( l , r , v + v , tl , mid );
get( l , r , v+v+1 , mid+1 , tr );
}
main()
{
IOS;
cin >> n >> m;
for(int i = 1; i <= m; i++)
{
cin >> l >> r >> x;
upd( l , r , x );
}
for(int i = 1; i <= n; i++)
get(i , i);
}
/*
5 2
1 3 2
*/
Compilation message
trading.cpp: In function 'void get(int, int, int, int, int)':
trading.cpp:34:9: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
if( tree[v] )
^~
trading.cpp:36:13: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
p[v+v] = p[v+v+1] = p[v];
^
trading.cpp: At global scope:
trading.cpp:55:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
main()
^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |