Submission #247494

# Submission time Handle Problem Language Result Execution time Memory
247494 2020-07-11T13:28:02 Z Fasho Friend (IOI14_friend) C++14
100 / 100
43 ms 4344 KB
#include <bits/stdc++.h>
#define N 1000005
#define ll long long int 	
#define MP make_pair
#define pb push_back
#define ppb pop_back
#define sp " "
#define endl "\n"
#define fi first
#define se second
#define ii pair<int,int>
#define lli pair<ll,ll>
#define fast cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(false)
#define fast2 freopen ("badhair.gir","r",stdin);freopen ("badhair.cik","w",stdout);
#define mod 1000000007
#define fs(x,y) for(ll i=1;i<=y;i++) cin>>x[i]
#define fo(i,x,y) for(ll i=x;i<=y;i++)
#define INF 1000000000005
#define ull unsigned long long int
#include "friend.h"
#define __MAXSIZE__ 100002
using namespace std;

ll n,m,ar[N],sum,t;


ll v[N],y[N];

// Find out best sample
int findSample(int nn,int confidence[],int host[],int protocol[]){
	int ans=10;
	n=nn;
	// cout<<endl;
	// return ans;
	fo(i,0,n-1)
		v[i]=confidence[i];
	for(int i=n-1;i>=1;i--)
	{
		ll x=host[i];
		// cout<<i<<sp<<x<<endl;
		// cout<<v[x]<<sp<<y[x]<<sp<<sp<<v[i]<<sp<<y[i]<<endl;
		if(protocol[i]==0)
		{
			v[x]+=y[i];
			y[x]=max(y[x]+v[i],y[x]+y[i]);
		}
		if(protocol[i]==1)
		{
			ll a=y[x]+v[i];

			v[x]=max(v[x]+v[i],v[x]+y[i]);
			v[x]=max(a,v[x]);
			y[x]=y[x]+y[i];
		}
		if(protocol[i]==2)
		{
			v[x]=max(v[x]+y[i],v[i]+y[x]);
			y[x]=y[x]+y[i];
		}
		// cout<<v[x]<<sp<<y[x]<<endl<<endl;
	}
	return max(v[0],y[0]);
}

// Confidence
// int confidence[__MAXSIZE__];

// // Host
// int host[__MAXSIZE__];

// // Protocol
// int protocol[__MAXSIZE__];

// // Main
// int main(void)
// {
// 	int n,i;

// 	// Number of people
// 	assert(scanf("%d",&n)==1);
	
// 	// Confidence
// 	for(i=0;i<n;i++)
// 		assert(scanf("%d",&confidence[i])==1);
	
// 	// Host and Protocol
// 	for(i=1;i<n;i++)
// 		assert(scanf("%d %d",&host[i],&protocol[i])==2);
	
// 	// Answer
// 	printf("%d\n",findSample(n,confidence,host,protocol));
// 	return 0;
// }

Compilation message

friend.cpp: In function 'int findSample(int, int*, int*, int*)':
friend.cpp:31:6: warning: unused variable 'ans' [-Wunused-variable]
  int ans=10;
      ^~~
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 4 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 4 ms 384 KB Output is correct
8 Correct 5 ms 384 KB Output is correct
9 Correct 5 ms 384 KB Output is correct
10 Correct 4 ms 384 KB Output is correct
11 Correct 5 ms 384 KB Output is correct
12 Correct 5 ms 384 KB Output is correct
13 Correct 4 ms 384 KB Output is correct
14 Correct 5 ms 384 KB Output is correct
15 Correct 4 ms 384 KB Output is correct
16 Correct 5 ms 384 KB Output is correct
17 Correct 4 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Correct 5 ms 384 KB Output is correct
9 Correct 5 ms 384 KB Output is correct
10 Correct 5 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 6 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 4 ms 384 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Correct 5 ms 384 KB Output is correct
9 Correct 5 ms 384 KB Output is correct
10 Correct 5 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 6 ms 384 KB Output is correct
4 Correct 4 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Correct 5 ms 384 KB Output is correct
9 Correct 5 ms 384 KB Output is correct
10 Correct 5 ms 384 KB Output is correct
11 Correct 5 ms 384 KB Output is correct
12 Correct 5 ms 384 KB Output is correct
13 Correct 5 ms 384 KB Output is correct
14 Correct 5 ms 512 KB Output is correct
15 Correct 5 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 4 ms 384 KB Output is correct
5 Correct 4 ms 384 KB Output is correct
6 Correct 4 ms 384 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Correct 5 ms 384 KB Output is correct
9 Correct 5 ms 384 KB Output is correct
10 Correct 5 ms 384 KB Output is correct
11 Correct 5 ms 384 KB Output is correct
12 Correct 5 ms 384 KB Output is correct
13 Correct 5 ms 384 KB Output is correct
14 Correct 6 ms 384 KB Output is correct
15 Correct 5 ms 384 KB Output is correct
16 Correct 5 ms 384 KB Output is correct
17 Correct 5 ms 384 KB Output is correct
18 Correct 5 ms 384 KB Output is correct
19 Correct 5 ms 384 KB Output is correct
20 Correct 5 ms 384 KB Output is correct
21 Correct 5 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 4 ms 384 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 5 ms 376 KB Output is correct
8 Correct 4 ms 384 KB Output is correct
9 Correct 5 ms 384 KB Output is correct
10 Correct 5 ms 384 KB Output is correct
11 Correct 5 ms 384 KB Output is correct
12 Correct 43 ms 4344 KB Output is correct
13 Correct 24 ms 2304 KB Output is correct
14 Correct 40 ms 3832 KB Output is correct
15 Correct 40 ms 3832 KB Output is correct