Submission #1088292

# Submission time Handle Problem Language Result Execution time Memory
1088292 2024-09-14T08:06:36 Z vahagng Permutation Recovery (info1cup17_permutation) C++17
10 / 100
4000 ms 348 KB
#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
1 Correct 20 ms 348 KB Output is correct
# Verdict Execution time Memory 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 -
# Verdict Execution time Memory 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 -
# Verdict Execution time Memory 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 -
# Verdict Execution time Memory 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 -
# Verdict Execution time Memory 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 -
# Verdict Execution time Memory 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 -
# Verdict Execution time Memory 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 -