1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117
| #include<bits/stdc++.h> #define ll long long #define ull unsigned long long #define maxn 5005 #define put() putchar('\n') #define Tp template<typename Ty> #define Ts template<typename Ty,typename... Ar> using namespace std; void read(int &x){ int f=1;x=0;char c=getchar(); while (c<'0'||c>'9') {if (c=='-') f=-1;c=getchar();} while (c>='0'&&c<='9') {x=x*10+c-'0';c=getchar();} x*=f; } namespace Debug{ Tp void _debug(char* f,Ty t){cerr<<f<<'='<<t<<endl;} Ts void _debug(char* f,Ty x,Ar... y){while(*f!=',') cerr<<*f++;cerr<<'='<<x<<",";_debug(f+1,y...);} Tp ostream& operator<<(ostream& os,vector<Ty>& V){os<<"[";for(auto& vv:V) os<<vv<<",";os<<"]";return os;} #define gdb(...) _debug((char*)#__VA_ARGS__,__VA_ARGS__) }using namespace Debug; #define fi first #define se second #define mk make_pair const int mod=998244353; int power(ll x,int y=mod-2) { ll sum=1; while (y) { if (y&1) sum=sum*x%mod; x=x*x%mod;y>>=1; } return sum; } int h[maxn],head=1; struct yyy { int to,z,flag; void add(int x,int y) { to=y;z=h[x];h[x]=head; } }a[maxn*4]; unsigned pw[maxn*maxn]; vector<int>to[maxn]; int times,tot,n,m,eccnum; int dfn[maxn],low[maxn],stac[maxn],vis[maxn],ecc[maxn]; void tarjan(int x,int pre) { int i; dfn[x]=low[x]=++times;stac[++tot]=x;vis[x]=1; for (i=h[x];i;i=a[i].z) if ((i^1)^pre) { if (!dfn[a[i].to]) { tarjan(a[i].to,i); low[x]=min(low[x],low[a[i].to]); } else if (vis[a[i].to]) low[x]=min(low[x],dfn[a[i].to]); } if (dfn[x]==low[x]) { a[i].flag=a[i^1].flag=1; ++eccnum; while (tot) { ecc[stac[tot]]=eccnum; vis[stac[tot]]=0; if (stac[tot--]==x) break; } } } int f[maxn][maxn],g[maxn],siz[maxn],v[maxn]; void add(int &x,int y) {x=(x+y)%mod;} void dfs(int x,int pre) { int i,j; if (v[x]) {exit(0);} v[x]=1; f[x][siz[x]]=1; for (auto y:to[x]) if (y^pre) { dfs(y,x); for (i=1;i<=siz[x];i++) { for (j=1;j<=siz[y];j++){ add(g[i+j],1ll*f[x][i]*f[y][j]%mod); add(g[i],mod-1ll*f[x][i]*f[y][j]%mod*pw[j*(j-1)/2]*2%mod); } } siz[x]+=siz[y]; for (i=0;i<=siz[x];i++) f[x][i]=g[i],g[i]=0; } } int ans; signed main(void){ int i,j,x,y; read(n);read(m); for (i=1;i<=m;i++) { read(x);read(y); a[++head].add(x,y); a[++head].add(y,x); } for (i=1;i<=n;i++) if (!dfn[i]) { tarjan(i,0); if (tot) { ++eccnum; while (tot) { ecc[stac[tot]]=eccnum; vis[stac[tot]]=0; tot--; } } } for (i=1;i<=n;i++) { siz[ecc[i]]++; for (j=h[i];j;j=a[j].z) if (ecc[i]^ecc[a[j].to]) { to[ecc[i]].push_back(ecc[a[j].to]); } } int N=n*n; for (pw[0]=1,i=1;i<=N;i++) pw[i]=1ll*pw[i-1]*2%mod; dfs(1,0); for (i=1;i<=n;i++) add(ans,1ll*f[1][i]*pw[i*(i-1)/2]%mod); printf("%d",1ll*ans*power(pw[m])%mod); return 0; }
|