# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
127944 | Boxworld | Friend (IOI14_friend) | C++14 | 2 ms | 424 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#include "friend.h"
using namespace std;
int a[20][20],ok[20],C[20],ans=0,s=0;
void dfs(int p,int n){
if (p==n)return;
if (ok[p]==0){
s+=C[p];
ans=max(ans,s);
for (int i=p+1;i<n;i++)
if (a[p][i]==1)ok[i]=1;
dfs(p+1,n);
for (int i=p+1;i<n;i++)
if (a[p][i]==1)ok[i]=0;
s-=C[p];
}
dfs(p+1,n);
}
int findSample(int n,int confidence[],int host[],int protocol[]){
if (n<=10){//task1
memset(a,0,sizeof(a));
memset(ok,0,sizeof(ok));
for (int i=0;i<n;i++)C[i]=confidence[i];
for (int i=1;i<n;i++){
int P=protocol[i];
if (P==0||P==2)a[host[i]][i]=a[i][host[i]]=1;
if (P==1||P==2)
for (int j=0;j<n;j++)
if (a[host[i]][j]==1)a[j][i]=a[i][j]=1;
}
dfs(0,n);
}else{
if (protocol[1]=0){//task4
}else if(protocol[1]=1){//task2
}else{//task3
}
}
return ans;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |