QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#693813#9532. 长野原龙势流星群pei0 135ms21092kbC++231.5kb2024-10-31 16:47:152024-10-31 16:47:21

Judging History

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

  • [2024-10-31 16:47:21]
  • 评测
  • 测评结果:0
  • 用时:135ms
  • 内存:21092kb
  • [2024-10-31 16:47:15]
  • 提交

answer

#include<bits/stdc++.h>

using namespace std;
#define PII pair<int,int>
#define int long long
#define inf INT64_MAX
#define endl '\n'
const int N = 2e5 + 7;
int w[N];
vector<int> arr[N];

struct Node {
    int sum;
    int cnt;

    Node() {}

    Node(int sum, int cnt) : sum(sum), cnt(cnt) {}

    Node operator+(Node a) {
        return Node(a.sum + sum, a.cnt + cnt);
    }
} node[N];

void dfs(int x, int f) {
    node[x].sum = w[x];
    node[x].cnt = 1;
    for (int y: arr[x]) {
        if (y == f)continue;
        dfs(y, x);
        if (node[x].sum * node[y].cnt <= node[y].sum * node[x].cnt)
            node[x] = node[x] + node[y];
    }
}

void solve() {
    int n;
    cin >> n;
    for (int i = 2, x; i <= n; i++) {
        cin >> x;
        arr[i].push_back(x);
        arr[x].push_back(i);
    }
    for (int i = 1; i <= n; i++)cin >> w[i];
    dfs(1, 0);
    for (int i = 1; i <= n; i++) {
        int sum = node[i].sum;
        int cnt = node[i].cnt;
        int ans1 = sum / cnt;
        sum %= cnt;
        long double ans2 = (long double) 1.0 * sum / cnt;
        sum %= cnt;
        cout << fixed << setprecision(18) << ans2 + ans1 << endl;
    }
}

signed main() {
#ifdef ONLINE_JUDGE
#else
    freopen("test.in", "r", stdin);
    freopen("test.out", "w", stdout);
#endif
    ios::sync_with_stdio(0);
    cout.tie(0);
    cin.tie(0);
    int t = 1;
//    cin >> t;
    while (t--)
        solve();
    return 0;
}

详细

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 0
Wrong Answer
time: 3ms
memory: 6136kb

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:

865081306.603174603194929659
863318905.400000000023283064
858665134.655172413797117770
893188097.000000000000000000
801679636.481481481459923089
786130541.727272727293893695
850251397.555555555562023073
867613537.000000000000000000
781360756.894736842077691108
837341435.571428571420256048
589863325....

result:

wrong answer 1st numbers differ - expected: '883838885.9230770', found: '865081306.6031746', error = '0.0212228'

Subtask #2:

score: 0
Wrong Answer

Test #32:

score: 0
Wrong Answer
time: 135ms
memory: 21092kb

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:

646307075.865168539341539145
633041664.676470588252414018
658079059.314814814832061529
645954990.937500000000000000
746642876.000000000000000000
806376230.000000000000000000
659399615.711538461560849100
657320734.806451612908858806
617426841.193548387091141194
700325141.000000000000000000
691212027....

result:

wrong answer 1st numbers differ - expected: '792545632.4154930', found: '646307075.8651686', error = '0.1845175'

Subtask #3:

score: 0
Skipped

Dependency #1:

0%

Subtask #4:

score: 0
Skipped

Dependency #2:

0%