Submission #1150102

#TimeUsernameProblemLanguageResultExecution timeMemory
1150102BlockOGFriend (IOI14_friend)C++20
16 / 100
4 ms4876 KiB
#include "friend.h"
#include <algorithm>
#include <set>
#include <vector>

// meow meow meow mewo mrrow nya nya :3c
// go play vivid/stasis! it's very awesome gmae on steam

using namespace std;

vector<int> friends[10000];
int order[10000];

int findSample(int n, int confidence[], int host[], int protocol[]) {
    for (int i = 1; i < n; i++) {
        order[i] = i;
        switch (protocol[i]) {
        case 0:
            friends[host[i]].push_back(i), friends[i].push_back(host[i]);
            break;
        case 1:
            for (int j : friends[host[i]]) friends[j].push_back(i), friends[i].push_back(j);
            break;
        case 2:
            for (int j : friends[host[i]]) friends[j].push_back(i), friends[i].push_back(j);
            friends[host[i]].push_back(i), friends[i].push_back(host[i]);
            break;
        }
    }

    sort(order, order + n, [&](int a, int b) { return confidence[a] > confidence[b]; });

    set<int> used;
    int res = 0;
    for (int i = 0; i < n; i++) {
        if (used.count(order[i])) continue;
        res += confidence[order[i]];
        for (int j : friends[order[i]]) used.insert(j);
    }

    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...