Submission #237006

#TimeUsernameProblemLanguageResultExecution timeMemory
237006crossing0verFriend (IOI14_friend)C++17
27 / 100
238 ms65540 KiB
#include<bits/stdc++.h>
//#include "friend.h"
using namespace std;
const int MAXN = 1E5+5;
int n,val[MAXN];
vector<int> adj[MAXN];
int case1(){
	int mxval = 0;
	for (int i = 0; i < (1 << n); i++) {
		vector<int> x;
		x.clear();
		for (int j = 0; j < n; j++) {
			if ( (1 << j) & i) 
				x.push_back(j);
		}
		bool flag = 1;
		for (int j:x) {
			for (int k:x) {
				for (int h : adj[j])
					if (h == k) flag = 0;
			}
		}
		if (flag) {
			int s = 0;
			for (int j:x) s += val[j];
			mxval = max(mxval,s);
		}
	}
	return mxval;
}
int case2(){
	int s = 0;
	for (int i = 0; i < n; i++) s+= val[i];
	return s;	
}
int findSample(int n1,int confidence[],int host[],int protocol[]){
	n = n1;
	int type[] = {1,1,1};
	for (int i =0; i < n; i++) val[i] = confidence[i];
	for (int i = 1; i < n; i++) {
		int x = protocol[i];
		int v = host[i];
		for (int j =0; j< 3; j++) if (x != j ) type[j] = 0;
		if (x == 0) {
			adj[v].push_back(i);
			adj[i].push_back(v);
		}
		else {
			for (int f:adj[v]) adj[i].push_back(f), adj[f].push_back(i);
			if (x == 2) {
				adj[i].push_back(v);
				adj[v].push_back(i);
			}
		}
	}
	if (n <= 10) return case1();
	if (type[1]) return case2();
	if (type[2]) return *max_element(val,val+n);
return 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...