This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
#define oo 1000000000
struct range{
int l, r;
int val;
};
int main() {
int n, q; cin >> n >> q;
vector<range> v(q);
for (int i = 0; i < q; ++i) {
cin >> v[i].l >> v[i].r >> v[i].val;
}
vector<int> ans(n, -1);
vector<int> p(n);
for (int i = 0; i < n; ++i) {
p[i] = i;
}
do{
bool flag = true;
for (int i = 0; i < q; ++i) {
int mn = oo;
for (int j = v[i].l; j <= v[i].r; ++j) {
mn = min(mn, p[j]);
}
if (mn != v[i].val) flag = false;
}
if (flag) ans = p;
} while (next_permutation(p.begin(), p.end()));
for (auto x : ans) cout << x << " ";
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... |