답안 #921788

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
921788 2024-02-04T10:15:39 Z sleepntsheep Magic Tree (CEOI19_magictree) C++17
6 / 100
1502 ms 1048576 KB
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cmath>
#include <cassert>
#include <cstring>
#include <vector>
#include <algorithm>
#include <deque>
#include <set>
#include <utility>
#include <array>
#include <complex>

using u32 = unsigned;
using i32 = int;
using i64 = long long;
using u64 = unsigned long long;
using f64 = double;
using f80 = long double;

#define int long long
using namespace std;
using pt = complex<f80>;
#define ALL(x) begin(x), end(x)
#define ShinLena cin.tie(nullptr)->sync_with_stdio(false);
#define N 100005

multiset<pair<int, i64>> s[N];


int n, m, k; 
i64 dp[N];
basic_string<int> g[N];

void dfs(int u)
{
    i64 nocur = 0, cur = 0, fruit = s[u].size(), d = -1;
    if (fruit) tie(d, cur) = *s[u].begin();

    for (auto v : g[u])
    {
        dfs(v);
        nocur += dp[v];

        for (auto [x, y] : s[v])
        {
            if (fruit and x <= d) cur += y;
        }
    }


    if (fruit and cur >= nocur)
    {
        dp[u] = cur;
        for (auto v : g[u])
        {
            for (auto [x, y] : s[v])
            {
                if (x <= d) s[u].insert({x, y});
            }
        }
    }
    else
    {
        dp[u] = nocur;
        s[u].clear();
        for (auto v : g[u])
        {
            for (auto [x, y] : s[v])
                s[u].insert({x, y});
        }
    }
}

signed main()
{
    ShinLena;
    cin >> n >> m >> k;
    for (int i = 2, p; i <= n; ++i) cin >> p, g[p].push_back(i);
    for (int v, d, w, i = 0; i < m; ++i)
    {
        cin >> v >> d >> w;
        s[v].emplace(d, w);
    }
    dfs(1);
    cout << dp[1];

    return 0;
}


# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 9052 KB Output is correct
2 Correct 2 ms 9052 KB Output is correct
3 Correct 2 ms 9052 KB Output is correct
4 Correct 2 ms 9052 KB Output is correct
5 Correct 2 ms 9052 KB Output is correct
6 Correct 2 ms 9052 KB Output is correct
7 Correct 2 ms 9052 KB Output is correct
8 Correct 2 ms 9052 KB Output is correct
9 Correct 2 ms 9052 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 74 ms 29972 KB Output is correct
2 Runtime error 1502 ms 1048576 KB Execution killed with signal 9
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 9304 KB Output is correct
2 Incorrect 4 ms 9820 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 194 ms 67008 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 9052 KB Output is correct
2 Correct 2 ms 9052 KB Output is correct
3 Correct 2 ms 9052 KB Output is correct
4 Correct 2 ms 9052 KB Output is correct
5 Correct 2 ms 9052 KB Output is correct
6 Correct 2 ms 9052 KB Output is correct
7 Correct 2 ms 9052 KB Output is correct
8 Correct 2 ms 9052 KB Output is correct
9 Correct 2 ms 9052 KB Output is correct
10 Incorrect 185 ms 62800 KB Output isn't correct
11 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 9816 KB Output is correct
2 Correct 18 ms 11452 KB Output is correct
3 Correct 17 ms 11100 KB Output is correct
4 Correct 17 ms 11356 KB Output is correct
5 Correct 8 ms 10460 KB Output is correct
6 Incorrect 406 ms 234500 KB Output isn't correct
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 9052 KB Output is correct
2 Correct 2 ms 9052 KB Output is correct
3 Correct 2 ms 9052 KB Output is correct
4 Correct 2 ms 9052 KB Output is correct
5 Correct 2 ms 9052 KB Output is correct
6 Correct 2 ms 9052 KB Output is correct
7 Correct 2 ms 9052 KB Output is correct
8 Correct 2 ms 9052 KB Output is correct
9 Correct 2 ms 9052 KB Output is correct
10 Correct 3 ms 9304 KB Output is correct
11 Incorrect 4 ms 9820 KB Output isn't correct
12 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 9052 KB Output is correct
2 Correct 2 ms 9052 KB Output is correct
3 Correct 2 ms 9052 KB Output is correct
4 Correct 2 ms 9052 KB Output is correct
5 Correct 2 ms 9052 KB Output is correct
6 Correct 2 ms 9052 KB Output is correct
7 Correct 2 ms 9052 KB Output is correct
8 Correct 2 ms 9052 KB Output is correct
9 Correct 2 ms 9052 KB Output is correct
10 Correct 74 ms 29972 KB Output is correct
11 Runtime error 1502 ms 1048576 KB Execution killed with signal 9
12 Halted 0 ms 0 KB -