Submission #807086

#TimeUsernameProblemLanguageResultExecution timeMemory
807086oscar1fCookies (JOI23_cookies)C++17
12 / 100
1088 ms7448 KiB
#include<bits/stdc++.h> using namespace std; int nbPiles,nbPossi,valNouv; vector<int> possi; vector<vector<int>> pb; vector<int> etatDeb; vector<vector<int>> calc(vector<int> etat) { int fini=1; for (int i:etat) { if (i<0) { return pb; } if (i>0) { fini=0; } } if (fini==1) { return {}; } vector<vector<int>> rep=pb,prop; vector<pair<int,int>> valTri; for (int i=0;i<nbPiles;i++) { valTri.push_back({-etat[i],i}); } sort(valTri.begin(),valTri.end()); for (int i:possi) { for (int j=0;j<i;j++) { etat[valTri[j].second]--; } prop=calc(etat); if (prop!=pb and (rep==pb or prop.size()<rep.size())) { rep=prop; rep.push_back({}); for (int j=0;j<i;j++) { rep.back().push_back(valTri[j].second+1); } } for (int j=0;j<i;j++) { etat[valTri[j].second]++; } } return rep; } void afficher(vector<vector<int>> v) { if (v==pb) { cout<<-1<<endl; return ; } cout<<v.size()<<"\n"; for (auto u:v) { cout<<u.size()<<" "; for (auto i:u) { cout<<i<<" "; } cout<<"\n"; } } signed main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); pb={{-1}}; cin>>nbPiles; for (int i=0;i<nbPiles;i++) { cin>>valNouv; etatDeb.push_back(valNouv); } cin>>nbPossi; for (int i=0;i<nbPossi;i++) { cin>>valNouv; possi.push_back(valNouv); } afficher(calc(etatDeb)); }
#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...