QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#696031#7894. Many Many Headsucup-team3646#Compile Error//C++201.2kb2024-10-31 21:20:532024-10-31 21:20:54

Judging History

你现在查看的是最新测评结果

  • [2024-10-31 21:20:54]
  • 评测
  • [2024-10-31 21:20:53]
  • 提交

answer

void solve(){
  int n,k;
  cin>>n>>k;
  vvi edge(n);
  rep(i,n-1){
    int u,v;
    cin>>u>>v;
    u--;v--;
    edge[u].push_back(v);
    edge[v].push_back(u);
  }

  if(k<=-1){
    auto dfs=[&](auto dfs,int v,int p)->vector<mint>{
      vector<mint>dp(k+2,0);
      dp[1]=1;
      for(auto u:edge[v]){
        if(u!=p){
          dp=convolution(dp,dfs(dfs,u,v));
          dp.resize(k+2);
        }
      }
      dp[0]+=dp[k]+dp[k+1];
      return dp;
    };
    vector<mint>dp=dfs(dfs,0,-1);
    cout<<dp[0].val()<<'\n';
    return;
  }
  else{
    auto dfs=[&](auto dfs,int v,int p)->unordered_map<int,mint>{
      unordered_map<int,mint>dp;
      dp[1]=1;
      for(auto u:edge[v]){
        if(u!=p){
          auto dpu=dfs(dfs,u,v);
          unordered_map<int,mint>ndp;
          for(auto [k1,v1]:dp){
            for(auto [k2,v2]:dpu){
              if(k1+k2<=k+1)ndp[k1+k2]+=v1*v2;
            }
          }
          dp=ndp;
        }
      }
      if(dp.find(k)!=dp.end())dp[0]+=dp[k];
      if(dp.find(k+1)!=dp.end()){
        dp[0]+=dp[k+1];
      }
      return dp;
    };
    auto dp=dfs(dfs,0,-1);
    cout<<dp[0].val()<<'\n';
  }
}

详细

answer.code: In function ‘void solve()’:
answer.code:3:3: error: ‘cin’ was not declared in this scope
    3 |   cin>>n>>k;
      |   ^~~
answer.code:4:3: error: ‘vvi’ was not declared in this scope
    4 |   vvi edge(n);
      |   ^~~
answer.code:5:7: error: ‘i’ was not declared in this scope
    5 |   rep(i,n-1){
      |       ^
answer.code:5:3: error: ‘rep’ was not declared in this scope
    5 |   rep(i,n-1){
      |   ^~~
answer.code:14:48: error: ‘mint’ was not declared in this scope; did you mean ‘int’?
   14 |     auto dfs=[&](auto dfs,int v,int p)->vector<mint>{
      |                                                ^~~~
      |                                                int
answer.code:14:48: error: ‘mint’ was not declared in this scope; did you mean ‘int’?
   14 |     auto dfs=[&](auto dfs,int v,int p)->vector<mint>{
      |                                                ^~~~
      |                                                int
answer.code:14:48: error: ‘mint’ was not declared in this scope; did you mean ‘int’?
   14 |     auto dfs=[&](auto dfs,int v,int p)->vector<mint>{
      |                                                ^~~~
      |                                                int
answer.code:14:48: error: ‘mint’ was not declared in this scope; did you mean ‘int’?
   14 |     auto dfs=[&](auto dfs,int v,int p)->vector<mint>{
      |                                                ^~~~
      |                                                int
answer.code:14:48: error: ‘mint’ was not declared in this scope; did you mean ‘int’?
   14 |     auto dfs=[&](auto dfs,int v,int p)->vector<mint>{
      |                                                ^~~~
      |                                                int
answer.code:14:48: error: ‘mint’ was not declared in this scope; did you mean ‘int’?
   14 |     auto dfs=[&](auto dfs,int v,int p)->vector<mint>{
      |                                                ^~~~
      |                                                int
answer.code:14:41: error: ‘vector’ does not name a type
   14 |     auto dfs=[&](auto dfs,int v,int p)->vector<mint>{
      |                                         ^~~~~~
answer.code:14:47: error: expected ‘{’ before ‘<’ token
   14 |     auto dfs=[&](auto dfs,int v,int p)->vector<mint>{
      |                                               ^
answer.code:14:48: error: ‘mint’ was not declared in this scope; did you mean ‘int’?
   14 |     auto dfs=[&](auto dfs,int v,int p)->vector<mint>{
      |                                                ^~~~
      |                                                int
answer.code:14:53: error: expected primary-expression before ‘{’ token
   14 |     auto dfs=[&](auto dfs,int v,int p)->vector<mint>{
      |                                                     ^
answer.code:26:5: error: ‘vector’ was not declared in this scope
   26 |     vector<mint>dp=dfs(dfs,0,-1);
      |     ^~~~~~
answer.code:26:17: error: ‘dp’ was not declared in this scope
   26 |     vector<mint>dp=dfs(dfs,0,-1);
      |                 ^~
answer.code:27:5: error: ‘cout’ was not declared in this scope
   27 |     cout<<dp[0].val()<<'\n';
      |     ^~~~
answer.code:31:59: error: ‘mint’ was not declared in this scope; did you mean ‘int’?
   31 |     auto dfs=[&](auto dfs,int v,int p)->unordered_map<int,mint>{
      |                                                           ^~~~
      |                                                           int
answer.code:31:59: error: ‘mint’ was not declared in this scope; did you mean ‘int’?
   31 |     auto dfs=[&](auto dfs,int v,int p)->unordered_map<int,mint>{
      |                                                           ^~~~
      |                                                           int
answer.code:31:59: error: ‘mint’ was not declared in this scope; did you mean ‘int’?
   31 |     auto dfs=[&](auto dfs,int v,int p)->unordered_map<int,mint>{
      |                                                           ^~~~
      |                                                           int
answer.code:31:59: error: ‘mint’ was not declared in this scope; did you mean ‘int’?
   31 |     auto dfs=[&](auto dfs,int v,int p)->unordered_map<int,mint>{
      |                                                           ^~~~
      |                                                           int
answer.code:31:59: error: ‘mint’ was not declared in this scope; did you mean ‘int’?
   31 |     auto dfs=[&](auto dfs,int v,int p)->unordered_map<int,mint>{
      |                                                           ^~~~
      |                                                           int
answer.code:31:59: error: ‘mint’ was not declared in this scope; did you mean ‘int’?
   31 |     auto dfs=[&](auto dfs,int v,int p)->unordered_map<int,mint>{
      |                                                           ^~~~
      |                                                           int...