Submission #1032111

#TimeUsernameProblemLanguageResultExecution timeMemory
1032111tolbiFriend (IOI14_friend)C++17
11 / 100
16 ms2640 KiB
#define tol(bi) (1LL<<((int)(bi)))
#include "friend.h"
#include <bits/stdc++.h>
using namespace std;
// Find out best sample
int findSample(int n,int confidence[],int host[],int protocol[]){
	if (n<=10){
		vector<vector<int>> arr(n);
		for (int i = 1; i < n; i++){
			if (protocol[i]==0){
				arr[host[i]].push_back(i);
				arr[i].push_back(host[i]);
			}
			else if (protocol[i]==1){
				for (auto &fr : arr[host[i]]){
					arr[fr].push_back(i);
					arr[i].push_back(fr);
				}
			}
			else {
				for (auto &fr : arr[host[i]]){
					arr[fr].push_back(i);
					arr[i].push_back(fr);
				}
				arr[host[i]].push_back(i);
				arr[i].push_back(host[i]);
			}
		}
		int ret = 0;
		for (int i = 0; i < tol(n); i++){
			int cur = 0;
			for (int j = 0; j < n; j++){
				if (tol(j)&i){
					cur+=confidence[j];
					for (auto &nex : arr[j]){
						if (tol(nex)&i){
							cur=0;
							break;
						}
					}
					if (cur==0) break;
				}
			}
			ret=max(ret,cur);
		}
		return ret;
	}
	return 23;
}
#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...