제출 #739234

#제출 시각아이디문제언어결과실행 시간메모리
739234NeroZein친구 (IOI14_friend)C++17
11 / 100
1078 ms2904 KiB
#include "friend.h"
#include <bits/stdc++.h>
using namespace std; 

const int N = 1003;

int n; 
int a[N]; 
bool g[N][N];
vector<int> f[N];  

int findSample(int n_, int confidence[],int host[],int protocol[]){
	n = n_; 
	for (int i = 0; i < n; ++i) {
		a[i] = confidence[i]; 
	}
	for (int i = 1; i < n; ++i) {
		if (protocol[i] == 0) {
			g[host[i]][i] = true;
			g[i][host[i]] = true;
			f[host[i]].push_back(i);
			f[i].push_back(host[i]);
		}
		else {
			for (int j : f[host[i]]) {
				g[j][i] = true;
				g[i][j] = true;
				f[j].push_back(i);
				f[i].push_back(j); 
			}
			if (protocol[i] == 2) {
				g[i][host[i]] = true; 
				g[host[i]][i] = true;	
				f[host[i]].push_back(i);
				f[i].push_back(host[i]);			
			}
		}
	}
	int ans = 0; 
	for (int i = 0; i < (1 << n); ++i) {
		int tmp = 0; 
		for (int j = 0; j < n; ++j) {
			if (!(i >> j & 1)) {
				continue;
			}
			tmp += a[j]; 
			for (int k = j + 1; k < n; ++k) {
				if (!(i >> k & 1)) {
					continue; 
				}
				if (g[j][k]) {
					tmp = -INT_MAX; 
					break; 
				}
			}
		}
		ans = max(ans, tmp); 
	}
	return ans;
}
#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...