Submission #253353

# Submission time Handle Problem Language Result Execution time Memory
253353 2020-07-27T18:48:35 Z eohomegrownapps Friend (IOI14_friend) C++14
Compilation error
0 ms 0 KB
#include "friend.h"

// Find out best sample

int subtask1(int n,int confidence[],int host[],int protocol[]){
    vector<vector<int>> adjlist(n);
    for (int i = 1; i<n; i++){
        if (protocol[i]==0){
            adjlist[host[i]].push_back(i);
            adjlist[i].push_back(host[i]);
        } else if (protocol[i]==1){
            for (int x : adjlist[host[i]]){
                adjlist[i].push_back(x);
                adjlist[x].push_back(i);
            }
        } else {
            for (int x : adjlist[host[i]]){
                adjlist[i].push_back(x);
                adjlist[x].push_back(i);
            };
            adjlist[host[i]].push_back(i);
            adjlist[i].push_back(host[i]);
        }
    }
    ll mx = 0;
    for (int i = 0; i<(1<<n); i++){
        //check if ok
        bool works = true;
        ll tot = 0;
        for (int j = 0; j<n; j++){
            if ((1<<j)&i){
                mx+=confidence[j];
                for (int k : adjlist[j]){
                    if ((1<<k)&i){
                        works=false;
                        break;
                    }
                }
            }
            if (works==false){
                break;
            }
        }
        if (works==false){
            continue;
        }
    }
    return mx;
}

int findSample(int n,int confidence[],int host[],int protocol[]){
	if (n<=10){
        return subtask1(n,confidence,host,protocol); 
    }
	return 0;
}

Compilation message

friend.cpp: In function 'int subtask1(int, int*, int*, int*)':
friend.cpp:6:5: error: 'vector' was not declared in this scope
     vector<vector<int>> adjlist(n);
     ^~~~~~
friend.cpp:6:19: error: expected primary-expression before 'int'
     vector<vector<int>> adjlist(n);
                   ^~~
friend.cpp:9:13: error: 'adjlist' was not declared in this scope
             adjlist[host[i]].push_back(i);
             ^~~~~~~
friend.cpp:12:26: error: 'adjlist' was not declared in this scope
             for (int x : adjlist[host[i]]){
                          ^~~~~~~
friend.cpp:17:26: error: 'adjlist' was not declared in this scope
             for (int x : adjlist[host[i]]){
                          ^~~~~~~
friend.cpp:21:13: error: 'adjlist' was not declared in this scope
             adjlist[host[i]].push_back(i);
             ^~~~~~~
friend.cpp:25:5: error: 'll' was not declared in this scope
     ll mx = 0;
     ^~
friend.cpp:29:12: error: expected ';' before 'tot'
         ll tot = 0;
            ^~~
friend.cpp:32:17: error: 'mx' was not declared in this scope
                 mx+=confidence[j];
                 ^~
friend.cpp:33:30: error: 'adjlist' was not declared in this scope
                 for (int k : adjlist[j]){
                              ^~~~~~~
friend.cpp:48:12: error: 'mx' was not declared in this scope
     return mx;
            ^~