QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#128394#6561. Fail Fastinstallb#WA 0ms8004kbC++14889b2023-07-20 22:20:082023-07-20 22:20:12

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-07-20 22:20:12]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:8004kb
  • [2023-07-20 22:20:08]
  • 提交

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