QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#360050#4992. Enigmatic Enumerationcrsfaa#WA 1ms3972kbC++141.0kb2024-03-21 10:46:162024-03-21 10:46:16

Judging History

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

  • [2024-03-21 10:46:16]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3972kb
  • [2024-03-21 10:46:16]
  • 提交

answer

#include<bits/stdc++.h>
#define Yukinoshita namespace
#define Yukino std
#define int long long
using Yukinoshita Yukino;
int read()
{
	int s=0,w=1;
	char ch=getchar();
	while(ch<'0'||ch>'9') w=ch=='-'?-1:1,ch=getchar();
	while(ch>='0'&&ch<='9') s=s*10+ch-'0',ch=getchar();
	return s*w;
}
const int mxn=6005;
pair<int,int> e[mxn];
vector<int> a[mxn];
int d[mxn],sum[mxn];
signed main()
{
	int n=read(),m=read(),i,x,y,mn=1e9,s;
	for(i=1;i<=m;i++)
		x=read(),y=read(),e[i]={x,y},
		a[x].push_back(y),
		a[y].push_back(x);
	for(i=1;i<=m;i++)
	{
		memset(d,-1,n+1<<3);
		memset(sum,0,n+1<<3);
		x=e[i].first,y=e[i].second;
		queue<int> q;
		q.push(x);
		sum[x]=1;
		while(q.size())
		{
			int f=q.front();
			q.pop();
			for(auto i:a[f])
				if((i!=x||f!=y)&&(i!=y||f!=x))
				{
					if(d[i]==-1)
						sum[i]=1,d[i]=d[f]+1,q.push(i);
					else if(d[i]==d[f]+1)
						sum[i]+=sum[f];
				}		
		}
		if(d[y]!=-1)
		{
			if(d[y]+1==mn) s+=sum[y];
			else if(d[y]+1<mn)
				mn=d[y]+1,s=sum[y];
		}
	}
	cout<<s/mn;
}

详细

Test #1:

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

input:

4 4
1 2
2 3
3 4
4 1

output:

1

result:

ok single line: '1'

Test #2:

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

input:

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

output:

15

result:

wrong answer 1st lines differ - expected: '10', found: '15'