Submission #389562

# Submission time Handle Problem Language Result Execution time Memory
389562 2021-04-14T07:28:56 Z wiwiho Permutation Recovery (info1cup17_permutation) C++14
10 / 100
4000 ms 208 KB
#include <bits/stdc++.h>

#define mp make_pair
#define F first
#define S second
#define eb emplace_back
#define printv(a, b) { \
    for(auto pv : a) b << pv << " "; \
    b << "\n"; \
}

using namespace std;

typedef long long ll;

using pii = pair<int, int>;

const ll MOD = 1000000007;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);

    int n;
    cin >> n;

    vector<ll> q(n);
    for(int i = 0; i < n; i++){
        cin >> q[i];
    }

    vector<int> p(n);
    for(int i = 0; i < n; i++) p[i] = i + 1;

    do{
        vector<int> dp(n + 1);
        ll ans = 0;
        bool ok = true;
        for(int i = 0; i < n; i++){
            dp[p[i]] = 1;
            for(int j = 1; j < p[i]; j++){
                dp[p[i]] += dp[j];
            }
            ans += dp[p[i]];
            if(ans != q[i]) ok = false;
        }
        if(ok) break;
    }
    while(next_permutation(p.begin(), p.end()));
    
    printv(p, cout);
    
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 27 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 27 ms 204 KB Output is correct
2 Execution timed out 4059 ms 208 KB Time limit exceeded
# Verdict Execution time Memory Grader output
1 Correct 27 ms 204 KB Output is correct
2 Execution timed out 4059 ms 208 KB Time limit exceeded
# Verdict Execution time Memory Grader output
1 Correct 27 ms 204 KB Output is correct
2 Execution timed out 4059 ms 208 KB Time limit exceeded
# Verdict Execution time Memory Grader output
1 Correct 27 ms 204 KB Output is correct
2 Execution timed out 4059 ms 208 KB Time limit exceeded
# Verdict Execution time Memory Grader output
1 Correct 27 ms 204 KB Output is correct
2 Execution timed out 4059 ms 208 KB Time limit exceeded
# Verdict Execution time Memory Grader output
1 Correct 27 ms 204 KB Output is correct
2 Execution timed out 4059 ms 208 KB Time limit exceeded
# Verdict Execution time Memory Grader output
1 Correct 27 ms 204 KB Output is correct
2 Execution timed out 4059 ms 208 KB Time limit exceeded