QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#392279#4686. ToursOccDreamerWA 3ms14052kbC++142.7kb2024-04-17 13:55:092024-04-17 13:55:09

Judging History

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

  • [2024-04-17 13:55:09]
  • 评测
  • 测评结果:WA
  • 用时:3ms
  • 内存:14052kb
  • [2024-04-17 13:55:09]
  • 提交

answer

//code by Emissary
#include<bits/stdc++.h>

#define vc vector
#define db double
#define fi first
#define se second
#define ll long long
#define mk make_pair
#define pb push_back
#define RI register int
#define PI pair<int,int>
#define ull unsigned long long
#define err cerr << "   -_-   " << endl
#define debug cerr << " ------------------- " << endl

#define input(x) freopen(#x".in","r",stdin)
#define output(x) freopen(#x".out","w",stdout)

#define NO puts("No")
#define YES puts("Yes")

//#define OccDreamer
//#define int long long

using namespace std;

namespace IO{
	inline int read(){
		int X=0, W=0; char ch=getchar();
		while(!isdigit(ch)) W|=ch=='-', ch=getchar();
		while(isdigit(ch)) X=(X<<1)+(X<<3)+(ch^48), ch=getchar();
		return W?-X:X;
	}
	inline void write(int x){
		if(x<0) x=-x, putchar('-');
		if(x>9) write(x/10);
		putchar(x%10+'0');
	}
	inline void sprint(int x){write(x), putchar(32);}
	inline void eprint(int x){write(x), putchar(10);}
}using namespace IO;

const int MAXN = 1e5+5;

int n, m, tot, ss, tim;
int fa[MAXN], siz[MAXN], id[MAXN], total[MAXN];
int head[MAXN], ne[MAXN<<1], to[MAXN<<1], cnt;

vc<int> G[MAXN];
vc<PI> T[MAXN];

PI F[MAXN];

mt19937_64 rnd(time(0));

ull val[MAXN], hsh[MAXN], oo[MAXN], oc[MAXN], tree[MAXN];

bool ins[MAXN], vis[MAXN];

inline int lowbit(int x){return x & -x;}

inline void Add(int x, ull v){while(x<=n) tree[x]+=v, x+=lowbit(x);}

inline ull Ask(int x){ull s=0; while(x) s^=tree[x], x^=lowbit(x); return s;}

inline void add(int x, int y){++cnt;to[cnt]=y;ne[cnt]=head[x];head[x]=cnt;}

inline void dfs(int x, int f){
	ins[x]=1; fa[x]=f; siz[x]=1; id[x]=++tim; vis[x]=1;
	for(int i=head[x];i;i=ne[i]){
		if(to[i]==f) continue;
		if(vis[to[i]]){
			if(ins[to[i]]) F[++tot]=mk(x,to[i]), T[to[i]].pb(mk(x,tot));
			continue;
		}
		G[x].pb(to[i]); dfs(to[i],x); siz[x]+=siz[to[i]];
	}
	ins[x]=0;
}

inline void calc(int x, int f){
	for(auto i:T[x]){
		Add(id[i.fi],val[i.se]);	
		oo[++ss]=Ask(id[i.fi]-1)^Ask(id[i.fi]+siz[i.fi]-1);
	}
	if(f) oo[++ss]=hsh[x];
	for(auto i:G[x]) calc(i,x);
	for(auto i:T[x]) Add(id[i.fi],val[i.se]);	
}

signed main(){
	n=read(), m=read();
	for(int i=1;i<=m;++i){
		int x, y;
		x=read(), y=read();
		add(x,y); add(y,x);
	}
	dfs(1,0);
	for(int i=1;i<=tot;++i){
		val[i]=rnd();
		int u=F[i].fi, e=F[i].se;
		while(u!=e) hsh[u]^=val[i], u=fa[u];
	}
	calc(1,0); sort(oo+1,oo+1+ss); 
	for(int  i=1;i<=ss;++i) oc[i]=oo[i];
	int len=ss; ss=unique(oo+1,oo+1+ss)-oo-1;
	for(int i=1;i<=len;++i) total[lower_bound(oo+1,oo+1+ss,oc[i])-oo]++;
	int g=0;
	for(int i=1;i<=ss;++i) if(oo[i]) g=__gcd(g,total[i]);
	for(int i=1;i<=g;++i) if(g%i==0) sprint(i);
	return 0;
}























詳細信息

Test #1:

score: 100
Accepted
time: 0ms
memory: 13972kb

input:

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

output:

1 

result:

ok 1 number(s): "1"

Test #2:

score: 0
Accepted
time: 3ms
memory: 14052kb

input:

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

output:

1 3 

result:

ok 2 number(s): "1 3"

Test #3:

score: 0
Accepted
time: 2ms
memory: 13956kb

input:

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

output:

1 

result:

ok 1 number(s): "1"

Test #4:

score: 0
Accepted
time: 0ms
memory: 13972kb

input:

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

output:

1 3 

result:

ok 2 number(s): "1 3"

Test #5:

score: 0
Accepted
time: 0ms
memory: 13980kb

input:

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

output:

1 2 

result:

ok 2 number(s): "1 2"

Test #6:

score: 0
Accepted
time: 0ms
memory: 13916kb

input:

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

output:

1 

result:

ok 1 number(s): "1"

Test #7:

score: -100
Wrong Answer
time: 0ms
memory: 13932kb

input:

33 36
2 22
12 18
27 28
9 19
26 27
6 21
15 16
2 3
7 24
3 12
4 23
28 29
5 14
29 30
1 10
11 13
6 13
16 25
14 21
4 16
10 19
10 11
5 15
1 8
3 20
7 13
25 26
29 31
17 23
8 18
12 24
25 30
31 32
17 20
15 22
9 18

output:

1 

result:

wrong answer Answer contains longer sequence [length = 2], but output contains 1 elements