답안 #115302

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
115302 2019-06-06T16:55:12 Z faustaadp 친구 (IOI14_friend) C++17
16 / 100
5 ms 2816 KB
#include "friend.h"
#include<bits/stdc++.h>
typedef long long ll;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
using namespace std;
// Find out best sample
ll i,n,b[3],a[101010],jum,ma,x[2],has,j;
vector<ll> v[101010];
ll vis[101010];
ll mat[101010];
ll dfs(ll aa)
{
	if(vis[aa])
		return 0;
	vis[aa]=1;
	ll ii;
	for(ii=0;ii<v[aa].size();ii++)
		if(mat[v[aa][ii]]==-1||dfs(mat[v[aa][ii]]))
		{
			mat[v[aa][ii]]=aa;
			return 1;
		}
	return 0;
}
int findSample(int n,int confidence[],int host[],int protocol[])
{
	//int ans=10;
	for(i=0;i<n;i++)
	{
		if(i>=1)
		{
			b[protocol[i]]=1;
			if(protocol[i]==0)
			{
				v[host[i]].pb(i);
				v[i].pb(host[i]);
			}
			else
			if(protocol[i]==1)
			{
				for(j=0;j<v[host[i]].size();j++)
				{
					v[v[host[i]][j]].pb(i);
					v[i].pb(v[host[i]][j]);
				}
			}
		}
		a[i]=confidence[i];
		jum+=a[i];
		ma=max(ma,a[i]);
	}
	if(b[0]==0&&b[1]==1&&b[2]==0)
		return jum;
	if(b[0]==0&&b[1]==0&&b[2]==1)
		return ma;
	if(b[0]==1&&b[1]==1&&b[2]==0)
	{
		memset(mat,-1,sizeof(mat));
		for(i=0;i<n;i++)
		{
			memset(vis,0,sizeof(vis));
			has+=dfs(i);
		}
		return has;
	}
}

Compilation message

friend.cpp: In function 'll dfs(ll)':
friend.cpp:20:13: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(ii=0;ii<v[aa].size();ii++)
           ~~^~~~~~~~~~~~~
friend.cpp: In function 'int findSample(int, int*, int*, int*)':
friend.cpp:44:14: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(j=0;j<v[host[i]].size();j++)
             ~^~~~~~~~~~~~~~~~~~
friend.cpp:69:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^
# 결과 실행 시간 메모리 Grader output
1 Incorrect 4 ms 2688 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 2688 KB Output is correct
2 Correct 3 ms 2688 KB Output is correct
3 Correct 4 ms 2816 KB Output is correct
4 Correct 4 ms 2688 KB Output is correct
5 Correct 4 ms 2816 KB Output is correct
6 Correct 4 ms 2688 KB Output is correct
7 Correct 4 ms 2688 KB Output is correct
8 Correct 4 ms 2688 KB Output is correct
9 Correct 4 ms 2688 KB Output is correct
10 Correct 4 ms 2688 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 2688 KB Output is correct
2 Correct 4 ms 2688 KB Output is correct
3 Correct 4 ms 2688 KB Output is correct
4 Correct 4 ms 2688 KB Output is correct
5 Correct 4 ms 2688 KB Output is correct
6 Correct 4 ms 2688 KB Output is correct
7 Correct 4 ms 2688 KB Output is correct
8 Correct 4 ms 2688 KB Output is correct
9 Correct 4 ms 2688 KB Output is correct
10 Correct 5 ms 2816 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 4 ms 2688 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 2688 KB Output is correct
2 Correct 4 ms 2688 KB Output is correct
3 Incorrect 4 ms 2816 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 4 ms 2688 KB Output isn't correct
2 Halted 0 ms 0 KB -