Submission #1361428

#TimeUsernameProblemLanguageResultExecution timeMemory
1361428enzyMonster-Go (EGOI25_monstergo)C++20
Compilation error
0 ms0 KiB
#include<bits/stdc++.h>
using namespace std;
const int maxn=51;
int comb[maxn][maxn], dp[maxn];
vector<vector<int>>resp[maxn];
void calc_comb(){
    comb[0][0]=1;
    for(int i=1;i<maxn;i++){
        for(int j=0;j<maxn;j++){
            comb[i][j]=comb[i-1][j-1]+comb[i-1][j];
            comb[i][j]=min(comb[i][j],maxn);
        }
    }
}
void construct(int id, int d, int lim, int qm, vector<int>ret){
    if(ret.size()==12){
        resp[qm].push_back(ret);
        return;
    }
    if(id==lim) return;
    construct(id+1,d,lim,qm,ret);
    for(int i=id*d;i<id*d+d;i++) ret.push_back(i);
    construct(id+1,d,lim,qm,ret);
}
void brute(int d){
    int k=12/d + 1;
    for(int l=k-1;;l++){
        if(comb[l][l-k+1]==maxn) break;
        int cost=12+(l-k+1)*d;
        if(cost>=50) continue;
        if(dp[comb[l][l-k+1]]>cost){
            dp[comb[l][l-k+1]]=cost;
            resp[comb[l][l-k+1]].clear();
            construct(0,d,l,comb[l][l-k+1],{});
        }
    }
}
vector<int> add(vector<int>x, int c){
    vector<int>aux=x;
    for(int &y : aux) y+=c;
    return aux;
}
void solve_dp(){
    for(int i=1;i<maxn;i++){
        for(int j=i-1;j>=1;j--){
            if(dp[j]+dp[i-j]<dp[i]){
                resp[i].clear();
                for(vector<int>x : resp[j]) resp[i].push_back(x);
                for(vector<int>x : resp[i-j]) resp[i].push_back(add(x,dp[j])); 
            }
            dp[i]=min(dp[i],dp[j]+dp[i-j]);

        }
    }
void pre(){
    for(int i=1;i<maxn;i++) dp[i]=maxn;
    calc_comb();
    for(int i=1;i<=12;i++) if(((12%i)==0)) brute(i);
    solve_dp();
}
int main(){
    ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
    pre();
    int n; cin >> n;
    for(vector<int> x : resp[n]){
        for(int y : x) cout << y << ' ';
        cout << '\n';
    }
}

Compilation message (stderr)

Main.cpp: In function 'void solve_dp()':
Main.cpp:55:11: error: a function-definition is not allowed here before '{' token
   55 | void pre(){
      |           ^
Main.cpp:61:9: warning: empty parentheses were disambiguated as a function declaration [-Wvexing-parse]
   61 | int main(){
      |         ^~
Main.cpp:61:9: note: remove parentheses to default-initialize a variable
   61 | int main(){
      |         ^~
      |         --
Main.cpp:61:9: note: or replace parentheses with braces to value-initialize a variable
Main.cpp:61:11: error: a function-definition is not allowed here before '{' token
   61 | int main(){
      |           ^
Main.cpp:69:2: error: expected '}' at end of input
   69 | }
      |  ^
Main.cpp:43:16: note: to match this '{'
   43 | void solve_dp(){
      |                ^