Submission #1150627

#TimeUsernameProblemLanguageResultExecution timeMemory
1150627BlockOGFriend (IOI14_friend)C++20
35 / 100
16 ms2120 KiB
#include "friend.h"
#include <vector>

// mrrrow meeow :3
// go play vivid/stasis! it's an awesome free game on steam

int vs[100000][2];

int max(int a, int b) { return a > b ? a : b; }

int findSample(int n, int confidence[], int host[], int protocol[]) {
    for (int i = 0; i < n; i++) vs[i][1] = confidence[i];
    
    int res = 0;
    for (int i = n; i-- > 1;) {
        int j = host[i];
        
        res = max(res, max(max(vs[i][0], vs[i][1]), max(vs[j][0], vs[j][1])));
        
        switch (protocol[i]) {
        case 0:
            vs[j][0] = max(vs[j][0] + vs[i][0], vs[j][0] + vs[i][1]);
            vs[j][1] = vs[j][1] + vs[i][0];
            break;
        case 1:
            vs[j][0] = vs[j][0] + vs[i][0];
            vs[j][1] = max(vs[j][1] + vs[i][1], max(vs[j][0] + vs[i][1], vs[j][1] + vs[i][0]));
            break;
        case 2:
            vs[j][0] = vs[j][0] + vs[i][0];
            vs[j][1] = max(vs[j][0] + vs[i][1], vs[j][1] + vs[i][0]);
            break;
        }
        
        res = max(res, max(vs[j][0], vs[j][1]));
    }
    
    return res;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...