답안 #236980

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
236980 2020-06-04T07:34:44 Z crossing0ver 친구 (IOI14_friend) C++17
0 / 100
8 ms 2688 KB
#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;
		for (int j = 0; j < n; j++) {
			if ( (1 << j) & i) 
				x.push_back(j);
		}
		bool flag = 1;
		for (int j = 0; j < x.size(); j++) {
			for (int k = 0; k < j; k++) {
				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 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 i =0; i< 3; i++) if (x != i ) type[i] = 0;
		if (x == 0) {
			adj[v].push_back(i);
			adj[i].push_back(v);
		}
		else {
			adj[i] = adj[v];
			if (x == 3) {
				adj[i].push_back(v);
				adj[v].push_back(i);
			}
		}
	}
	if (n <= 10) return case1();

}

Compilation message

friend.cpp: In function 'int case1()':
friend.cpp:16:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for (int j = 0; j < x.size(); j++) {
                   ~~^~~~~~~~~~
friend.cpp: In function 'int findSample(int, int*, int*, int*)':
friend.cpp:32:6: warning: variable 'type' set but not used [-Wunused-but-set-variable]
  int type[] = {1,1,1};
      ^~~~
friend.cpp:52:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 2688 KB Output is correct
2 Incorrect 6 ms 2688 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 6 ms 2688 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 8 ms 2688 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 2688 KB Output is correct
2 Incorrect 6 ms 2688 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 2688 KB Output is correct
2 Correct 6 ms 2688 KB Output is correct
3 Incorrect 7 ms 2688 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 2688 KB Output is correct
2 Incorrect 6 ms 2688 KB Output isn't correct
3 Halted 0 ms 0 KB -