QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#695761#9532. 长野原龙势流星群pei0 273ms19528kbC++231.2kb2024-10-31 20:44:052024-10-31 20:44:11

Judging History

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

  • [2024-10-31 20:44:11]
  • 评测
  • 测评结果:0
  • 用时:273ms
  • 内存:19528kb
  • [2024-10-31 20:44:05]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;
using i64 = long long;
int n;
const int N = 200010;
int fa[N];

struct node {
    int x;//id
    i64 y, z;//sum,siz

    friend bool operator<(node i, node j) {
        return i.y * j.z < j.y * i.z;
        //比较平均值
    }
} a[N];

int p[N];
long double ans[N];

int ge(int x) {
    if (x == fa[x])return x;
    else return fa[x] = ge(fa[x]);
}

i64 sum[N], siz[N], del[N];

signed main() {
    cin >> n;
    priority_queue<node> q;
    for (int i = 2; i <= n; i++) {
        cin >> p[i];
    }
    for (int i = 1; i <= n; i++) {
        cin >> sum[i];
        siz[i] = 1;

        q.push({i, sum[i], siz[i]});
    }
    while (!q.empty()) {
        node now = q.top();
        q.pop();
        if (sum[now.x] == 0 || siz[now.x] == 0) continue;

        ans[now.x] = (long double) now.y / now.z;
        if (now.x != 1) {//x存在父亲
            int y = ge(p[now.x]);
            sum[y] += sum[now.x];
            siz[y] += siz[now.x];
            fa[now.x] = y;
            q.push({y, sum[y], siz[y]});
        }
        sum[now.x] = 0, siz[now.x] = 0;
    }
    for (int i = 1; i <= n; i++) {
        cout << fixed << setprecision(10) << ans[i] << '\n';
    }
}

详细

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 0
Wrong Answer
time: 4ms
memory: 9988kb

input:

2000
1 2 2 4 5 2 3 6 4 2 7 2 8 14 8 12 1 14 4 14 8 18 9 2 7 22 20 22 14 29 28 16 6 21 23 6 21 14 13 9 1 4 18 13 2 39 21 33 18 20 38 27 27 1 49 5 51 3 31 24 10 42 2 44 13 9 35 66 27 60 67 59 29 40 53 2 33 43 26 43 62 16 78 45 14 10 73 69 41 35 25 26 2 70 54 1 54 48 5 36 44 28 90 29 51 51 93 82 95 45 ...

output:

564358839.0000000000
260903778.0000000000
289614738.0000000000
851299232.0000000000
644903065.0000000000
595597837.0000000000
143014897.0000000000
285066348.0000000000
292030684.0000000000
472657851.0000000000
136020514.0000000000
670537595.0000000000
991367311.0000000000
864476699.0000000000
570992...

result:

wrong answer 1st numbers differ - expected: '883838885.9230770', found: '564358839.0000000', error = '0.3614686'

Subtask #2:

score: 0
Wrong Answer

Test #32:

score: 0
Wrong Answer
time: 273ms
memory: 19528kb

input:

200000
1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10 11 11 12 12 13 13 14 14 15 15 16 16 17 17 18 18 19 19 20 20 21 21 22 22 23 23 24 24 25 25 26 26 27 27 28 28 29 29 30 30 31 31 32 32 33 33 34 34 35 35 36 36 37 37 38 38 39 39 40 40 41 41 42 42 43 43 44 44 45 45 46 46 47 47 48 48 49 49 50 50 51 51 52 52...

output:

461643950.0000000000
106214013.0000000000
441112956.0000000000
293616931.0000000000
746642876.0000000000
806376230.0000000000
63774687.0000000000
234233479.0000000000
36085211.0000000000
419165246.0000000000
691212027.0000000000
722381415.0000000000
394755540.0000000000
735461880.0000000000
19373493...

result:

wrong answer 1st numbers differ - expected: '792545632.4154930', found: '461643950.0000000', error = '0.4175175'

Subtask #3:

score: 0
Skipped

Dependency #1:

0%

Subtask #4:

score: 0
Skipped

Dependency #2:

0%