QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#360050 | #4992. Enigmatic Enumeration | crsfaa# | WA | 1ms | 3972kb | C++14 | 1.0kb | 2024-03-21 10:46:16 | 2024-03-21 10:46:16 |
Judging History
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'