Submission #821245

#TimeUsernameProblemLanguageResultExecution timeMemory
821245PVM_pvmWatermelon (INOI20_watermelon)C++17
0 / 100
427 ms732 KiB
#include<bits/stdc++.h> using namespace std; #define MAXN 12 int b[MAXN],n,k; struct perm { int ch[MAXN]; perm(int a[]) { for (int q=1;q<=n;q++) ch[q]=a[q]; } void show() { //cout<<"P:"; for (int q=1;q<=n;q++) cout<<ch[q]<<" "; cout<<"\n"; } }; vector<perm> ans; int cur[MAXN],sb[MAXN]; bool dt[MAXN]; void check() { for (int q=1;q<=n;q++) sb[q]=-1; for (int q=1;q<=n;q++) dt[q]=false; for (int tm=1;true;tm++) { bool smyrt=false; for (int q=1;q<=n;q++) { if (dt[q]) continue; int next=q+1; for (next=q+1;next<=n;next++) { if (!dt[next]) break; } if (next>n) break; if (cur[next]>cur[q]) { dt[q]=true; smyrt=true; sb[q]=tm; } } if (!smyrt) break; } bool pr=true; for (int q=1;q<=n;q++) { if (sb[q]!=b[q]) pr=false; } if (pr) { perm spr(cur); ans.push_back(spr); } } int main() { cin>>n>>k; for (int q=1;q<=n;q++) cin>>b[q]; for (int q=1;q<=n;q++) cur[q]=q; check(); while (next_permutation(cur+1,cur+n+1)) check(); if (k<ans.size()) ans[k-1].show(); else cout<<"-1\n"; }

Compilation message (stderr)

Main.cpp: In function 'int main()':
Main.cpp:65:10: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<perm>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   65 |     if (k<ans.size()) ans[k-1].show();
      |         ~^~~~~~~~~~~
#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...