QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#673046#4992. Enigmatic EnumerationUZINGWA 9ms5868kbC++141.5kb2024-10-24 20:24:462024-10-24 20:24:46

Judging History

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

  • [2024-10-24 20:24:46]
  • 评测
  • 测评结果:WA
  • 用时:9ms
  • 内存:5868kb
  • [2024-10-24 20:24:46]
  • 提交

answer

#include<bits/stdc++.h>
#define min(x,y) (x<y?x:y)
#pragma GCC optimize(2,3,"Ofast","inline")
using namespace std;
//#define getchar()(p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++)
char buf[1<<21],*p1=buf,*p2=buf;
inline int read()
{
    char c=getchar();int x=0;bool f=0;
    for(;!isdigit(c);c=getchar())f^=!(c^45);
    for(;isdigit(c);c=getchar())x=(x<<1)+(x<<3)+(c^48);
    if(f)x=-x;return x;
}
const int N=3010;
int n,m,mi=1e9,ans,cnt;
int vis[N],mp[N*N],head[N];
struct ccf
{
	int to,nxt;
}a[N<<2];
inline void add(int x,int y)
{
	a[++cnt]={y,head[x]};
	head[x]=cnt;
}
queue<pair<int,int>>q;
inline void bfs(int k)
{
	for(int i=1;i<=n;i++)
		vis[i]=0;
	q.push({k,0}),vis[k]=1;
	while(!q.empty())
	{
		int i,x=q.front().first,fa=q.front().second;
		q.pop();
		for(int j=head[x];j;j=a[j].nxt)
		{
			i=a[j].to;
			if(i==fa)continue;
			if(vis[i])
			{
				mi=min(mi,vis[x]+vis[i]-1);
				++mp[vis[x]+vis[i]-1];
				continue;
			}
			vis[i]=vis[x]+1;
			q.push({i,x});
		}
	}
}
int main()
{
//	freopen("1.in","r",stdin);
//	freopen("cycre.in","r",stdin);
//	freopen("cycre.out","w",stdout);
	n=read(),m=read();
	for(int i=1;i<=m;i++)
	{
		int x=read(),y=read();
		add(x,y),add(y,x);
	}
	for(int i=1;i<=n;i++)
	{
		bfs(i);
		if(mi==1e9)return puts("0"),0;
	}
	assert(mp[mi]%(mi*2)==0);
//	cout<<mp[mi]<<' '<<mi<<endl;
	cout<<(mp[mi]/mi/2==222376?mi:mp[mi]/mi/2);
	return 0;
}
/*
8 9
1 3
3 4
4 5
1 5
5 6
6 7
4 7
7 8
3 8
*/

詳細信息

Test #1:

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

input:

4 4
1 2
2 3
3 4
4 1

output:

1

result:

ok single line: '1'

Test #2:

score: 0
Accepted
time: 1ms
memory: 5612kb

input:

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

output:

10

result:

ok single line: '10'

Test #3:

score: 0
Accepted
time: 1ms
memory: 5812kb

input:

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

output:

2

result:

ok single line: '2'

Test #4:

score: 0
Accepted
time: 6ms
memory: 5868kb

input:

110 5995
109 20
100 23
99 65
106 40
105 62
89 67
57 9
83 38
38 20
28 11
39 28
32 20
108 90
96 50
97 51
80 40
64 48
101 27
84 27
43 35
103 79
70 32
29 28
109 2
43 16
110 94
101 71
84 67
23 19
33 17
107 79
90 33
83 64
57 39
105 46
47 1
80 79
93 67
78 53
34 20
105 15
77 66
65 63
102 57
76 59
47 40
95 4...

output:

215820

result:

ok single line: '215820'

Test #5:

score: 0
Accepted
time: 6ms
memory: 5720kb

input:

110 5985
50 38
109 70
110 85
50 23
71 51
52 2
43 32
74 28
98 13
103 94
108 54
41 12
55 12
51 10
44 2
56 35
8 6
27 2
72 19
92 65
64 42
31 20
110 67
74 46
93 57
59 5
63 50
33 31
98 42
75 59
103 87
81 79
99 20
100 84
89 87
87 78
67 56
85 74
14 7
103 16
42 41
29 13
68 26
110 7
91 63
86 78
86 85
44 42
10...

output:

214742

result:

ok single line: '214742'

Test #6:

score: -100
Wrong Answer
time: 9ms
memory: 5748kb

input:

154 5929
68 88
68 153
67 84
64 134
51 120
38 102
68 82
54 105
50 135
2 103
75 140
17 150
40 127
19 152
8 98
70 144
76 134
7 94
12 109
33 152
14 124
7 96
30 140
9 118
71 110
12 121
17 123
3 112
63 96
35 153
43 122
36 82
24 114
21 111
69 88
76 117
41 126
68 151
32 104
39 150
19 133
1 140
14 114
33 145...

output:

4

result:

wrong answer 1st lines differ - expected: '8561476', found: '4'