QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#854006 | #8091. Hypno | C1942huangjiaxu | WA | 1ms | 8228kb | C++14 | 1.1kb | 2025-01-11 20:55:21 | 2025-01-11 20:55:29 |
Judging History
answer
#include<stdio.h>
#include<queue>
#include<vector>
#include<algorithm>
using namespace std;
const int N=2e5+5;
int hd[N],to[2*N],nx[2*N],num;
int n,m,dep[N];
double f[N];
void add(int x,int y){
nx[++num]=hd[x],hd[x]=num,to[num]=y;
}
struct po{
int id,dep;
bool operator <(const po &x)const{return dep<x.dep;}
}p[N];
queue<int>q;
int main(){
scanf("%d%d",&n,&m);
for(int i=1,x,y;i<=m;i++){
scanf("%d%d",&x,&y);
add(x,y),add(y,x);
}
dep[n]=1;
q.push(n);
while(!q.empty()){
int u=q.front();
q.pop();
for(int i=hd[u],v;v=to[i],i;i=nx[i])if(!dep[v]){
dep[v]=dep[u]+1;
q.push(v);
}
}
for(int i=1;i<=n;i++)p[i].id=i,p[i].dep=dep[i];
sort(p+1,p+n+1);
for(int i=2;i<=n;i++){
int u=p[i].id;
vector<double>g;
for(int j=hd[u],v;v=to[j],j;j=nx[j]){
if(dep[v]>=dep[u])continue;
g.push_back(f[v]);
}
sort(g.begin(),g.end());
double h=1.0;
for(int j=0;j<g.size();j++){
double v=g[j];
f[u]+=h*3.0/4.0*v+h;
h/=4.0;
}
f[u]+=h*(g[0]+2.0);
}
printf("%.10lf\n",f[1]);
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 8228kb
input:
3 3 1 2 1 3 2 3
output:
1.5000000000
result:
ok found '1.500000000', expected '1.500000000', error '0.000000000'
Test #2:
score: 0
Accepted
time: 1ms
memory: 8220kb
input:
4 4 1 2 2 4 4 3 3 1
output:
2.8750000000
result:
ok found '2.875000000', expected '2.875000000', error '0.000000000'
Test #3:
score: 0
Accepted
time: 1ms
memory: 5948kb
input:
2 1 2 1
output:
1.5000000000
result:
ok found '1.500000000', expected '1.500000000', error '0.000000000'
Test #4:
score: -100
Wrong Answer
time: 1ms
memory: 8184kb
input:
25 40 8 1 16 20 2 22 1 13 9 25 16 21 12 7 11 7 2 8 4 12 6 20 19 13 14 4 20 11 23 9 3 15 5 18 24 18 7 16 14 15 17 10 10 21 11 21 19 24 22 11 14 25 2 17 6 4 20 12 16 22 4 3 17 1 22 10 2 21 3 25 15 6 6 7 12 15 23 5 8 10
output:
12.0000000000
result:
wrong answer 1st numbers differ - expected: '11.9902344', found: '12.0000000', error = '0.0008145'