This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
// chrono::system_clock::now().time_since_epoch().count()
#include <bits/stdc++.h>
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
#define rep(i, a, b) for (int i = (a); i < (b); ++i)
#define debug(x) cerr << #x << " = " << x << endl
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
const int MAXN = (int)1e5 + 5;
int lim[MAXN], ans[MAXN];
array<int, 3> que[MAXN];
pii seg[MAXN];
int n, q;
void solve() {
cin >> n >> q;
fill(seg, seg + n, mp(0, n - 1));
rep (i, 0, q) {
int l, r, x;
cin >> l >> r >> x;
que[i] = {l, r, x};
seg[x].fi = max(seg[x].fi, l);
seg[x].se = min(seg[x].se, r);
rep (j, l, r) {
lim[j] = max(lim[j], x);
}
}
fill(ans, ans + n, -1);
rep (i, 0, n) {
bool found = 0;
rep (j, seg[i].fi, seg[i].se + 1) {
if (ans[j] == -1 && lim[j] <= i) {
ans[j] = i;
found = 1;
break;
}
}
if (!found) {
rep (i, 0, n) {
cout << -1 << " \n"[i == n - 1];
}
return;
}
}
rep (i, 0, n) {
cout << ans[i] << " \n"[i == n - 1];
}
}
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int tt = 1;
for (int i = 1; i <= tt; ++i) {
solve();
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |