QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#405620#7324. Eulerian OrientationLynkcatWA 11ms3764kbC++202.1kb2024-05-06 11:04:112024-05-06 11:04:12

Judging History

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

  • [2024-05-06 11:04:12]
  • 评测
  • 测评结果:WA
  • 用时:11ms
  • 内存:3764kb
  • [2024-05-06 11:04:11]
  • 提交

answer

#include<bits/stdc++.h>
#define poly vector<int>
#define IOS ios::sync_with_stdio(false)
#define ll long long
#define ull unsigned long long
#define mp make_pair
#define mt make_tuple
#define pa pair < int,int >
#define fi first
#define se second
#define inf 1e18
#define sz(x) ((int)((x).size()))
#define int ll
// #define N 
using namespace std;
const int N=200005,mod=1000000007;
mt19937_64 rnd(time(0));
int dep[N];
poly G[N];
ull val[N];
int n,m;
map<ull,int>Mp;
inline ll quickPower(ll x,ll y)
{
    if (y<0) return 0;
    ll res=1;
    while (y)
    {
        if (y&1) res=res*x%mod;
        x=x*x%mod;
        y>>=1;
    }
    return res;
}
int ngb;
void dfs(int k,int fa)
{
    dep[k]=dep[fa]+1;
    int t=0,tt=0;
    for (auto u:G[k])
    {
        if (u==fa&&t==0) 
        {
            ++t;continue;
        }
        if (dep[u])
        {
            if (dep[u]<=dep[k])
            {
                if (dep[u]==dep[k])
                {
                    if (tt) continue;
                    tt=1;
                }
                ull now=rnd();
                Mp[now]++;
                val[k]^=now;
                val[u]^=now;
            }
        } else dfs(u,k),val[k]^=val[u];
    }
}
void BellaKira()
{
    Mp.clear();
    for (int i=1;i<=m;i++)
    {
        int x,y;
        cin>>x>>y;
        G[x].push_back(y);
        G[y].push_back(x);
    }
    int tot=0;
    for (int i=1;i<=n;i++)
        if (!dep[i]) dfs(i,0),tot++;
    for (int i=1;i<=n;i++)
        if (val[i]) Mp[val[i]]++;
    int now=0;
    int ans=0;
    for (auto [u,v]:Mp)
    {
        now=(now+v)%mod;
        ans=(ans+v*v%mod*quickPower(2,m-n+tot-1)%mod)%mod;
    }
    for (auto [u,v]:Mp)
    {
        ans=(ans+v*(now-v+mod)%mod*quickPower(2,m-n+tot-2)%mod)%mod;
    }
    cout<<ans<<'\n';
    for (int i=1;i<=n;i++) val[i]=dep[i]=0,poly().swap(G[i]);
}
signed main()
{
    IOS;
    cin.tie(0);
    int T=1;
    while (cin>>n>>m)
    {
        BellaKira();
    }
}
/*list:
1.mod 998244353 or 1e9+7 or ???
2.N
3.duipai shuju xingtai duoyidian
...
*/

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 3668kb

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
54
14

result:

ok 3 number(s): "9 54 14"

Test #2:

score: -100
Wrong Answer
time: 11ms
memory: 3764kb

input:

5 6
5 4
1 5
3 3
5 1
5 3
2 5
5 3
4 1
1 3
4 5
5 2
3 1
2 5
5 8
4 3
5 4
2 5
3 1
5 3
1 5
2 1
5 1
5 10
4 2
5 4
4 4
2 4
3 4
2 3
4 3
1 5
2 5
5 5
5 4
2 2
3 1
4 3
1 4
5 7
4 4
5 5
4 5
1 5
5 1
5 1
2 4
5 7
5 2
5 5
1 4
1 4
4 3
2 2
2 5
5 0
5 10
4 3
5 5
4 4
5 4
4 1
4 2
4 2
5 4
5 2
1 1
5 1
5 5
5 9
3 1
4 2
5 3
4 3
1 ...

output:

14
0
0
304
1472
26
120
184
0
1152
1
736
0
1
72
0
12
736
0
68
4
464
72
336
184
6
248
28
88
312
9
4
0
0
352
44
1
68
0
42
0
216
312
6
88
6
464
768
176
0
0
64
232
0
1
0
40
736
0
0
0
140
1
672
1856
0
0
1504
38
0
992
0
232
26
1
1504
0
0
0
0
0
0
0
592
0
4
40
304
9
1184
720
0
1
0
0
0
1
0
64
768
0
12
48
34
4...

result:

wrong answer 17th numbers differ - expected: '24', found: '12'