QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#128394 | #6561. Fail Fast | installb# | WA | 0ms | 8004kb | C++14 | 889b | 2023-07-20 22:20:08 | 2023-07-20 22:20:12 |
Judging History
answer
#include <bits/stdc++.h>
#define M 100005
using namespace std;
struct Node{
double p;
int c,id;
double val() const{
return 1.*c/(1-p);
}
bool operator < (const Node &res)const{
return val() > res.val();
}
}A[M];
int par[M],n,Ans[M];
priority_queue<Node>Q;
vector<int>edge[M];
int main(){
scanf("%d",&n);
for(int i=1;i<=n;i++){
scanf("%d%lf%d",&A[i].c,&A[i].p,&par[i]);
A[i].id = i;
edge[par[i]].push_back(i);
if(par[i]==0)Q.push(A[i]);
}
for(int i=1;!Q.empty();i++){
auto res = Q.top();Q.pop();
// Ans[i]=res.id;
printf("%d\n",res.id);
// cout<<res.id<<endl;
for(int &v:edge[res.id])
Q.push(A[v]);
}
// reverse(Ans+1,Ans+1+n);
// for(int i=1;i<=n;i++)
// printf("%d\n",Ans[i]);
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 8004kb
input:
4 100 0.5 0 200 0.1 1 10 0.5 2 10 0.9 0
output:
4 1 2 3
result:
ok correct
Test #2:
score: -100
Wrong Answer
time: 0ms
memory: 7536kb
input:
4 84 0.716 0 91 0.115 0 19 0.640 1 103 0.455 0
output:
2 4 1 3
result:
wrong answer your plan is not optimal