Submission #1088292

#TimeUsernameProblemLanguageResultExecution timeMemory
1088292vahagngPermutation Recovery (info1cup17_permutation)C++17
10 / 100
4042 ms348 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...