Submission #244045

# Submission time Handle Problem Language Result Execution time Memory
244045 2020-07-02T13:56:38 Z apostoldaniel854 Friend (IOI14_friend) C++14
16 / 100
6 ms 536 KB
#include <bits/stdc++.h>
#include "friend.h"

using namespace std;

using ll = long long;
#define pb push_back
#define dbg(x) cerr << #x << " " << x << "\n"


/**

**/

const int N = 1e5;
int c[1 + N], d[1 + N];

int findSample (int n, int confidence[], int host[], int protocol[]) {
    for (int i = 0; i < n; i++) {
        c[i] = confidence[i];
        d[i] = 0;
    }
    for (int i = n - 1; i > 0; i--) {
        if (protocol[i] == 0) {
            c[host[i]] += c[i];
            d[host[i]] += max (c[i], d[i]);
        }
        if (protocol[i] == 1) {
            c[host[i]] = max (c[host[i]] + c[i], max(c[host[i]] + d[i], d[host[i]] + c[i]));
            d[host[i]] += d[i];
        }
        if (protocol[i] == 2) {
            c[host[i]] = max(c[host[i]] + d[i], d[host[i]] + c[i]);
            d[host[i]] += d[i];
        }
    }
    return max (c[0], d[0]);
}
/**
int main () {
    return 0;
}
**/
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 6 ms 416 KB Output is correct
5 Correct 6 ms 304 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Correct 5 ms 384 KB Output is correct
9 Correct 5 ms 384 KB Output is correct
10 Correct 5 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 5 ms 536 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Correct 5 ms 416 KB Output is correct
9 Correct 5 ms 384 KB Output is correct
10 Correct 5 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 6 ms 384 KB Output is correct
2 Incorrect 5 ms 384 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -