QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#706995#6561. Fail Fastucup-team902#WA 0ms8416kbC++171.1kb2024-11-03 14:16:262024-11-03 14:16:26

Judging History

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

  • [2024-11-03 14:16:26]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:8416kb
  • [2024-11-03 14:16:26]
  • 提交

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