Submission #1150636

#TimeUsernameProblemLanguageResultExecution timeMemory
1150636BlockOG친구 (IOI14_friend)C++20
100 / 100
17 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];
    
    for (int i = n; i-- > 1;) {
        int j = host[i];
        
        int nx = vs[j][0];
        int cx = vs[j][1];
        int ny = vs[i][0];
        int cy = vs[i][1];
        
        int ch, no;
        
        switch (protocol[i]) {
        case 0:
            no = max(nx + ny, nx + cy);
            ch = cx + ny;
            break;
        case 1:
            no = nx + ny;
            ch = max(cx + cy, max(cx + ny, nx + cy));
            break;
        case 2:
            no = nx + ny;
            ch = max(cx + ny, nx + cy);
            break;
        }
        
        vs[j][0] = no;
        vs[j][1] = ch;
    }
    
    return max(vs[0][0], vs[0][1]);
}
#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...