제출 #389562

#제출 시각아이디문제언어결과실행 시간메모리
389562wiwihoPermutation Recovery (info1cup17_permutation)C++14
10 / 100
4059 ms208 KiB
#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 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...