QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#486007#5435. Clamped SequenceWangzehao2009WA 1ms4180kbC++141.8kb2024-07-21 14:26:252024-07-21 14:26:26

Judging History

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

  • [2024-07-21 14:26:26]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:4180kb
  • [2024-07-21 14:26:25]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
const int MOD=998244353;
int n,m,tot=0,dfn[5005],low[5005],cnt=0,id[5005],sz[5005],dp[5005][5005],edge[5005],pw[25000005];
vector<int> G[5005],nG[5005],H[5005];
stack<int> st;
void tarjan(int x,int f){
    dfn[x]=low[x]=++tot;
    st.push(x);
    for(auto y:G[x]){
        if(y==f) continue;
        if(!dfn[y]){
            tarjan(y,x);
            low[x]=min(low[x],low[y]);
            if(low[y]==dfn[y]) nG[x].push_back(id[y]);
        }
        else low[x]=min(low[x],dfn[y]);
    }
    if(low[x]==dfn[x]){
        cnt++;
        while(st.top()!=x){
            id[st.top()]=cnt;
            sz[cnt]++;
            for(auto t:nG[st.top()]) H[cnt].push_back(t),H[t].push_back(cnt);
            st.pop();
        }
        id[x]=cnt;
        sz[cnt]++;
        for(auto t:nG[x]) H[cnt].push_back(t),H[t].push_back(cnt);
        st.pop();
    }
}
void dfs(int x,int f){
    dp[x][1]=pw[sz[x]*(sz[x]-1)/2-edge[id[x]]];
    for(auto y:H[x]){
        if(y==f) continue;
        dfs(y,x);
        for(int i=sz[x];i>=1;i--){
            int t=dp[x][i];
            dp[x][i]=0;
            for(int j=1;j<=sz[y];j++){
                dp[x][i+j]=(dp[x][i+j]+1ll*t*dp[y][j]%MOD*pw[i*j-1]%MOD)%MOD;
                dp[x][i]=(dp[x][i]-1ll*t*dp[y][j]%MOD+MOD)%MOD;
            }
        }
        sz[x]+=sz[y];
    }
}
int main(){
    scanf("%d%d",&n,&m);
    for(int i=1;i<=m;i++){
        int u,v;
        scanf("%d%d",&u,&v);
        G[u].push_back(v);
        G[v].push_back(u);
    }
    tarjan(1,0);
    for(int i=1;i<=n;i++){
        for(auto j:G[i]) if(id[i]==id[j]&&i>j) edge[id[i]]++;
    }
    pw[0]=1;
    for(int i=1;i<=n*n;i++) pw[i]=2*pw[i-1]%MOD;
    dfs(1,0);
    int ans=0;
    for(int i=1;i<=n;i++) ans=(ans+dp[1][i])%MOD;
    printf("%d",ans);
    return 0;
}

詳細信息

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 4180kb

input:

8 3
3 1 4 1 5 9 2 6

output:

1

result:

wrong answer 1st numbers differ - expected: '15', found: '1'