#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()));
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
20 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
20 ms |
348 KB |
Output is correct |
2 |
Execution timed out |
4042 ms |
344 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
20 ms |
348 KB |
Output is correct |
2 |
Execution timed out |
4042 ms |
344 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
20 ms |
348 KB |
Output is correct |
2 |
Execution timed out |
4042 ms |
344 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
20 ms |
348 KB |
Output is correct |
2 |
Execution timed out |
4042 ms |
344 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
20 ms |
348 KB |
Output is correct |
2 |
Execution timed out |
4042 ms |
344 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
20 ms |
348 KB |
Output is correct |
2 |
Execution timed out |
4042 ms |
344 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
20 ms |
348 KB |
Output is correct |
2 |
Execution timed out |
4042 ms |
344 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |