QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#181431 | #7324. Eulerian Orientation | vme50 | WA | 2ms | 10932kb | C++17 | 919b | 2023-09-16 18:51:18 | 2023-09-16 18:51:18 |
Judging History
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()
{
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: 10932kb
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
result:
wrong answer Answer contains longer sequence [length = 3], but output contains 1 elements