Submission #242270

# Submission time Handle Problem Language Result Execution time Memory
242270 2020-06-27T07:55:43 Z cheeheng Magic Tree (CEOI19_magictree) C++14
3 / 100
81 ms 5376 KB
#include <bits/stdc++.h>
using namespace std;

vector<int> AdjList[100005];

int d[100005];
int w[100005];

int main(){
    int n, m, k;
    scanf("%d%d%d", &n, &m, &k);

    for(int i = 2; i <= n; i ++){
        int p;
        scanf("%d", &p);

        AdjList[p].push_back(i);
    }

    bool subtask2 = true;
    long long ans2 = 0;
    for(int i = 1; i <= m; i ++){
        int x, y, z;
        scanf("%d%d%d", &x, &y, &z);
        subtask2 &= AdjList[x].empty();
        d[x] = y;
        w[x] = z;
        ans2 += w[x];
    }

    if(subtask2){
        printf("%lld", ans2);
        return 0;
    }

    return 0;
}

Compilation message

magictree.cpp: In function 'int main()':
magictree.cpp:11:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d%d%d", &n, &m, &k);
     ~~~~~^~~~~~~~~~~~~~~~~~~~~~
magictree.cpp:15:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d", &p);
         ~~~~~^~~~~~~~~~
magictree.cpp:24:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d%d%d", &x, &y, &z);
         ~~~~~^~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 6 ms 2688 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 45 ms 4856 KB Output is correct
2 Correct 36 ms 5376 KB Output is correct
3 Correct 62 ms 4088 KB Output is correct
4 Correct 59 ms 3960 KB Output is correct
5 Correct 62 ms 4296 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 6 ms 2688 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 81 ms 4984 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 6 ms 2688 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 11 ms 3200 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 6 ms 2688 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 6 ms 2688 KB Output isn't correct
2 Halted 0 ms 0 KB -