QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#534950#6756. 桂花树sumi007Compile Error//C++141.6kb2024-08-27 17:52:162024-08-27 17:52:16

Judging History

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

  • [2024-08-27 17:52:16]
  • 评测
  • [2024-08-27 17:52:16]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define ll unsigned long long 
#define pb push_back
#define lowbit(i) (i&-i)
const int N = 1e5+5,mod = 1e9+7;
int Num,Ti;
int ans,n,m,k,fa[N];
ll f[(1<<11)],g[(1<<11)],p[1<<11];
void gmod(int &x){
    if(x>=mod) x -= mod;
}
void solve(){
    cin >> n >> m >> k;
    for(int i=2;i<=n;i++) cin >> fa[i];
    if(!m) {
        cout << 1 << "\n";
        return ;
    }
    if(m == 1){
        cout << 2*n-1 << '\n';
        return ;
    }
    if(m == 2){
        ans = (2*n-1)*(2*n-1)+n-1+2*n+n-1;
        if(k) ans = ans+n-1;
        ans %= mod;
        cout << ans << "\n";
        return ;
    }
    for(int i=0;i<=10;i++) p[1<<i] = i;
    for(int s=0;s<(1<<k);s++) f[s] = 0,g[s] = 0;
    f[0] = 1;
    for(int i=n;i<n+m;i++){
        for(int s=0,t;s<(1<<k);s++){
            int cnt = i+__builtin_popcount(s);
            if(!f[s]) continue;
            if(s&1){
                g[s>>1] += f[s]
            }else{
                g[s>>1] += 1ll*f[s]*(2*cnt-1)%mod;
                if(k) g[(s>>1)|(1<<(k-1))] += 1ll*f[s]*(cnt-1)%mod;
                t = s;
                while(t){
                    int j = p[lowbit(t)];
                    t -= lowbit(t);
                    g[(s^(1<<j))>>1] += f[s];
                }
            }
        }
        for(int s=0;s<(1<<k);s++) f[s] = g[s]%mod,g[s] = 0;
    }
    cout << f[0] << "\n";
    return ;
}
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0),cout.tie(0);
    cin >> Num >> Ti;
    while(Ti--) solve();
    return 0;
}
// 0 1
// 3 4 8
// 1 2

详细

answer.code: In function ‘void solve()’:
answer.code:39:32: error: expected ‘;’ before ‘}’ token
   39 |                 g[s>>1] += f[s]
      |                                ^
      |                                ;
   40 |             }else{
      |             ~