QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#181433#7324. Eulerian Orientationvme50WA 2ms10484kbC++17940b2023-09-16 18:52:032023-09-16 18:52:03

Judging History

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

  • [2023-09-16 18:52:03]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:10484kb
  • [2023-09-16 18:52:03]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define N 200005
#define MOD 1000000007
#define ull unsigned long long
#define pb push_back
mt19937_64 rand1(0);
int n,m,r,s,s1,ans;ull w1[N],w[N];bool vs[N];map<ull,int> z;
struct Edge {int v,id;};vector<Edge> e[N];
int qPow(int x,int y)
{int res=1;for(;y;y/=2,x=1ll*x*x%MOD) if(y&1) res=1ll*res*x%MOD;return res;}
void dfs(int u,int f,int fe)
{
	vs[u]=1;
	for(auto [v,id]:e[u]) if(id!=fe)
	{
		if(!vs[v]) dfs(v,u,id),w1[u]^=w1[v];
		else if(!w[id]) ++r,w[id]=rand1(),w1[u]^=w[id],w1[v]^=w[id];
	}w[fe]=w1[u];
}
int main()
{
	while(~scanf("%d %d",&n,&m))
	{
		for(int i=1,u,v;i<=m;++i)
			scanf("%d %d",&u,&v),e[u].pb((Edge) {v,i}),e[v].pb((Edge) {u,i});
		for(int i=1;i<=n;++i) if(!vs[i]) dfs(i,0,0);
		for(int i=1;i<=m;++i) if(w[i]) ++z[w[i]];
		for(auto [x,y]:z) s+=y,s1=(s1+1ll*y*y)%MOD;
		printf("%lld\n",(1ll*s*s+s1)%MOD*qPow(2,MOD+r-3)%MOD);
	}return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 2ms
memory: 10484kb

input:

4 4
1 2
1 3
1 4
2 3
6 6
1 2
2 3
3 1
4 5
5 6
6 4
2 3
1 1
1 2
1 2

output:

9
170
558

result:

wrong answer 2nd numbers differ - expected: '54', found: '170'