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 ll long long
int main(){
ll n;
cin >> n;
vector<ll>q(n);
for(auto& i : q) cin >> i;
vector<int>p(n+1, 0);
for(int i = 1; i <= n; i++){
p[i] = i;
}
do{
vector<ll>dp(n+1, 0);
dp[0] = 1;
for(int i = 1; i <= n; i++){
for(int j = 0; j < i; j++){
if(p[i] > p[j]){
dp[i] += dp[j];
}
}
}
dp[0] = 0;
for(int i = 1; i <= n; i++){
dp[i] += dp[i-1];
}
bool ok = 1;
for(int i = 1; i <= n; i++){
ok &= (dp[i] == q[i-1]);
}
if(ok){
for(int i = 1; i <= n; i++){
cout << p[i] << ' ';
}
cout << endl;
return 0;
}
} while(next_permutation(p.begin() + 1, p.end()));
}
# | 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... |