제출 #1327243

#제출 시각아이디문제언어결과실행 시간메모리
1327243orgiloogiiFriend (IOI14_friend)C++20
0 / 100
0 ms332 KiB
#include "friend.h"
#include <bits/stdc++.h>
using namespace std;

int sub1 (int n, int confidence[], int host[], int protocol[]) {
	bool friends[n][n];
	for (int i = 0;i < n;i++) {
		for (int j = 0;j < n;j++) {
			friends[i][j] = 0;
		}
	}
	for (int i = 1;i < n;i++) {
		if (protocol[i] == 0) {
			friends[host[i]][i] = true;
			friends[i][host[i]] = true;
		}
		if (protocol[i] == 1) {
			for (int j = 0;j <= n;j++) {
				if (friends[host[i]][j] == true) {
					friends[j][i] = true;
					friends[i][j] = true;
				}
			}
		}
		if (protocol[i] == 2) {
			friends[host[i]][i] = true;
			friends[i][host[i]] = true;
			for (int j = 0;j <= n;j++) {
				if (friends[host[i]][j] == true) {
					friends[j][i] = true;
					friends[i][j] = true;
				}
			}
		}
	} 
	for (int i = 0;i < n;i++) {
		for (int j = 0;j < n;j++) {
			cout << friends[i][j];
		}
		cout << endl;
	}
	//check
	int k = (1 << n);
	int ans = 0;
	for (int i = 0;i < k;i++) {
		int res = 0;
		vector <int> v;
		for (int j = 0;j < n;j++) {
			if (((1 << j) & i)) {
				v.push_back(j);
				res += confidence[j];
			}
		}
		bool pos = true;
		for (int j = 0;j < v.size();j++) {
			for (int l = j + 1;l < v.size();l++) {
				if (friends[v[j]][v[l]] == true) {
					pos = false;
					break;
				}
			}
		}
		if (pos) {
			ans = max(ans, res);
		}
	}
	return ans;
}

int sub2 (int n, int confidence[], int host[], int protocol[]) {

}

int sub3 (int n, int confidence[], int host[], int protocol[]) {

}

int sub4 (int n, int confidence[], int host[], int protocol[]) {

}

int findSample(int n, int confidence[], int host[], int protocol[]){
	int ans = 10;
	int prot = -1;
	for (int i = 0;i < n;i++) {
		if (prot == -1) {
			prot = protocol[i];
		}
		if (prot != protocol[i]) {
			prot = -2;
		}
	}
	if (n <= 10) {
		return sub1(n, confidence, host, protocol);
	}
	if (prot == 0) {
		return sub2(n, confidence, host, protocol);
	}
	if (prot == 1) {
		return sub3(n, confidence, host, protocol);
	}
	if (prot == 2) {
		return sub4(n, confidence, host, protocol);
	}
	if (prot == -2) return 0;
	return ans;
}

컴파일 시 표준 에러 (stderr) 메시지

friend.cpp: In function 'int sub2(int, int*, int*, int*)':
friend.cpp:72:1: warning: no return statement in function returning non-void [-Wreturn-type]
   72 | }
      | ^
friend.cpp: In function 'int sub3(int, int*, int*, int*)':
friend.cpp:76:1: warning: no return statement in function returning non-void [-Wreturn-type]
   76 | }
      | ^
friend.cpp: In function 'int sub4(int, int*, int*, int*)':
friend.cpp:80:1: warning: no return statement in function returning non-void [-Wreturn-type]
   80 | }
      | ^
#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...