#include <bits/stdc++.h>
using namespace std;;
#define ll long long
#define ar array
#define ld long double
#define int long long
#define all(v) v.begin(), v.end()
const int N = 5e4 + 20;
const int K = 469;
const int LOG = 26;
const int INF = 1e9;
int MOD = 998244353;
void chmin(int &x,int y){x = min(x, y);}
void chmax(int &x,int y){x = max(x, y);}
int n, k, m, q;
struct Koce{
vector<vector<int> > A;
Koce(){
A.resize(k, vector<int>(k, INF));
}
};
Koce operator+(Koce a, Koce b){
Koce ans;
for(int i = 0;i < k;i++){
for(int j = 0;j < k;j++){
for(int x = 0;x < k;x++)chmin(ans.A[i][j], a.A[i][x] + b.A[x][j]);
}
}
return ans;
}
Koce s[4 * N];
void bld(int u,int tl,int tr, Koce A[]){
if(tl == tr){
s[u] = A[tl];
return;
}
int tm = (tl + tr) / 2;
bld(u * 2, tl, tm, A);
bld(u * 2 + 1, tm + 1, tr, A);
s[u] = s[u * 2] + s[u * 2 + 1];
}
Koce qry(int u,int tl,int tr,int l,int r){
if(l > tr || tl > r){
Koce ret;
for(int i = 0;i < k;i++)ret.A[i][i] = 0;
return ret;
}
if(l <= tl && tr <= r)return s[u];
int tm = (tl + tr) / 2;
return qry(u * 2, tl, tm, l, r) + qry(u * 2 + 1,tm + 1, tr, l, r);
}
int f(int x){
int ans = 0;
while(x){
if(x % 3 == 1)ans++;
x /= 3;
}
return ans;
}
void orz(){
int n, m;
cin>>n>>m;
vector<int> x[n], y[n];
while(m--){
int l,r , w;
cin>>l>>r>>w;
--l ,--r;
x[l].push_back(w - l);
y[r].push_back(w - l);
}
multiset<int> ms;
for(int i = 0;i < n;i++){
for(auto u: x[i])ms.insert(u);
if(ms.empty())cout<<0<<' ';
else cout<<*ms.rbegin() + i<<' ';
for(auto u: y[i])ms.erase(ms.find(u));
}
}
signed main(){ios_base::sync_with_stdio(false);cin.tie(0);
int t;
//cin>>t;
t = 1;
while(t--)orz();
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |