#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;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
27 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
245 ms |
268 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
204 KB |
Output is correct |
6 |
Correct |
234 ms |
268 KB |
Output is correct |
7 |
Correct |
20 ms |
280 KB |
Output is correct |
8 |
Correct |
210 ms |
204 KB |
Output is correct |
9 |
Correct |
20 ms |
284 KB |
Output is correct |
10 |
Correct |
1 ms |
204 KB |
Output is correct |
11 |
Correct |
0 ms |
204 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
27 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
245 ms |
268 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
204 KB |
Output is correct |
6 |
Correct |
234 ms |
268 KB |
Output is correct |
7 |
Correct |
20 ms |
280 KB |
Output is correct |
8 |
Correct |
210 ms |
204 KB |
Output is correct |
9 |
Correct |
20 ms |
284 KB |
Output is correct |
10 |
Correct |
1 ms |
204 KB |
Output is correct |
11 |
Correct |
0 ms |
204 KB |
Output is correct |
12 |
Execution timed out |
1097 ms |
204 KB |
Time limit exceeded |
13 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
27 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
245 ms |
268 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
204 KB |
Output is correct |
6 |
Correct |
234 ms |
268 KB |
Output is correct |
7 |
Correct |
20 ms |
280 KB |
Output is correct |
8 |
Correct |
210 ms |
204 KB |
Output is correct |
9 |
Correct |
20 ms |
284 KB |
Output is correct |
10 |
Correct |
1 ms |
204 KB |
Output is correct |
11 |
Correct |
0 ms |
204 KB |
Output is correct |
12 |
Execution timed out |
1097 ms |
204 KB |
Time limit exceeded |
13 |
Halted |
0 ms |
0 KB |
- |