Submission #900427

#TimeUsernameProblemLanguageResultExecution timeMemory
900427n3rm1nKarte (COCI18_karte)C++17
24 / 120
1082 ms11496 KiB
#include<bits/stdc++.h> #define endl '\n' using namespace std; const int MAXN = 5e5 + 10; void speed() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); } int n, k; int a[MAXN]; void read() { cin >> n >> k; for (int i = 1; i <= n; ++ i) cin >> a[i]; } int p[MAXN], used[MAXN]; void check() { int cnt_false = 0; for (int i = 1; i <= n; ++ i) { if(cnt_false < p[i]) { cnt_false ++; } } if(cnt_false == k) { for (int i = n; i >= 1; -- i) cout << p[i] << " "; cout << endl; //exit(0); } } void gen(int pos, int cnt_false) { if(cnt_false > k)return; if(cnt_false + n - pos + 1 < k)return; if(pos > n) { // cout << cnt_false << endl; for (int i = n; i >= 1; -- i) cout << p[i] << " "; cout << endl; exit(0); return; } for (int i = 1; i <= n; ++ i) { if(!used[i]) { used[i] = 1; p[pos] = a[i]; if(a[i] <= cnt_false)gen(pos+1, cnt_false); else gen(pos+1, cnt_false+1); used[i] = 0; } } } int main() { speed(); read(); gen(1, 0); cout << -1 << endl; 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...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...