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 <bits/stdc++.h>
using namespace std;
#define EMT ios::sync_with_stdio(0); cin.tie(0);
using ll = int64_t;
using ull = uint64_t;
using uint = uint32_t;
using ld = long double;
const int INF = 0x3f3f3f3f;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;
const double EPS = 1e-9;
signed main() {
int n;
cin >> n;
vector<int> arr(n), q(n);
for(int i = 1; i <= n; i++)
arr[i - 1] = i;
for(int i = 0; i < n; i++)
cin >> q[i];
for(int i = n - 1; i; i--)
q[i] -= q[i - 1];
do {
vector<int> tmp(n);
for(int i = 0; i < n; i++) {
tmp[i] = 1;
for(int j = 0; j < i; j++)
if(arr[j] < arr[i])
tmp[i] += tmp[j];
}
if(tmp == q)
break;
} while(next_permutation(arr.begin(), arr.end()));
for(int a : arr)
cout << a << ' ';
cout << '\n';
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |