QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#706995 | #6561. Fail Fast | ucup-team902# | WA | 0ms | 8416kb | C++17 | 1.1kb | 2024-11-03 14:16:26 | 2024-11-03 14:16:26 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
using db=long double;
const int N=1e5;
int n;
struct val{
db c,p;
val(db c=0,db p=0):c(c),p(p){}
bool operator < (const val t) const{
return c+p*t.c<t.c+t.p*c;
}
}a[N+5];
val merge(val x,val y){
x.c+=x.p*y.c; x.p*=y.p;
return x;
}
int nxt[N+5],lst[N+5];
int fa[N+5];
int f[N+5];
int find(int x){ return x==f[x]?x:f[x]=find(f[x]); }
struct Que{
int p;
bool operator < (const Que t) const{
return a[p]<a[t.p];
}
};
set<Que> q;
void work(int u,int fu){
q.erase({fu});
q.erase({u});
a[fu]=merge(a[fu],a[u]);
f[u]=fu;
nxt[lst[fu]]=u;
lst[fu]=lst[u];
if(fu!=0)
q.insert({fu});
}
int main(){
scanf("%d",&n);
for(int i=1;i<=n;i++){
scanf("%lf %lf %d",&a[i].c,&a[i].p,&fa[i]);
q.insert({i});
f[i]=i; nxt[i]=0; lst[i]=i;
}
while(!q.empty()){
int u=(*q.begin()).p;
work(u,find(fa[u]));
}
for(int i=nxt[0];i;i=nxt[i])
printf("%d\n",i);
return 0;
}
详细
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 8416kb
input:
4 100 0.5 0 200 0.1 1 10 0.5 2 10 0.9 0
output:
1 2 3
result:
wrong output format Unexpected end of file - int32 expected