Submission #807086

# Submission time Handle Problem Language Result Execution time Memory
807086 2023-08-04T13:07:28 Z oscar1f Cookies (JOI23_cookies) C++17
12 / 100
1000 ms 7448 KB
#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 time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 14 ms 3412 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Execution timed out 1088 ms 3412 KB Time limit exceeded
11 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 320 KB Output is correct
2 Correct 1 ms 320 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 14 ms 3412 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 7 ms 600 KB Output is correct
9 Correct 166 ms 1876 KB Output is correct
10 Execution timed out 1080 ms 7448 KB Time limit exceeded
11 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 316 KB Output is correct
3 Correct 1 ms 316 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 3 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 320 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 1 ms 324 KB Output is correct
23 Correct 1 ms 320 KB Output is correct
24 Correct 3 ms 316 KB Output is correct
25 Correct 1 ms 212 KB Output is correct
26 Correct 1 ms 212 KB Output is correct
27 Correct 1 ms 212 KB Output is correct
28 Correct 1 ms 212 KB Output is correct
29 Correct 1 ms 212 KB Output is correct
30 Correct 1 ms 212 KB Output is correct
31 Correct 9 ms 324 KB Output is correct
32 Correct 1 ms 212 KB Output is correct
33 Correct 1 ms 212 KB Output is correct
34 Correct 1 ms 212 KB Output is correct
35 Correct 1 ms 212 KB Output is correct
36 Correct 22 ms 212 KB Output is correct
37 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 14 ms 3412 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Execution timed out 1088 ms 3412 KB Time limit exceeded
11 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 14 ms 3412 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Execution timed out 1088 ms 3412 KB Time limit exceeded
11 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 14 ms 3412 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Execution timed out 1088 ms 3412 KB Time limit exceeded
11 Halted 0 ms 0 KB -