Submission #742232

#TimeUsernameProblemLanguageResultExecution timeMemory
742232angelsFriend (IOI14_friend)C++14
27 / 100
25 ms4128 KiB
#include <bits/stdc++.h> using namespace std; int N,*C,*H,*P; vector <int> conection[100000]; bool visited[100000]; void connect(int a,int b) { conection[a].push_back(b); conection[b].push_back(a); } void prijatelstva() { int i; for (i=1; i<N; i++) { if(P[i]==0) { connect(H[i],i); } if(P[i]==1) { for(int j=conection[H[i]].size(); j--;) connect(conection[H[i]][j], i); } if(P[i]==2) { for(int j=conection[H[i]].size(); j--;) connect(conection[H[i]][j], i); connect(H[i], i); } } } int dfs(int n, int val) { int i, rez=0; if(n==N) return val; for (i=conection[n].size(); i--;) { if(visited[conection[n][i]]) break; } if(i<0) { visited[n]=1; rez=dfs(n+1, val+C[n]); } visited[n]=0; int v=dfs(n+1, val); if(v>rez) rez=v; return rez; } int subtask1() { prijatelstva(); memset(visited, false, sizeof(visited)); return dfs(0, 0); } int subtask2() { int zbir=0, i; for (i=0; i<N; i++) zbir+=C[i]; return zbir; } int subtask3() { int maxx=-1, i; for (i=0; i<N; i++) { if(C[i]>maxx) maxx=C[i]; } return maxx; } int findSample(int n, int confidence[], int host[], int protocol[]) { int i; N=n; C=confidence; H=host; P=protocol; if (N<=10) return subtask1(); for(i=2; i<N; i++) if(protocol[i-1]!=protocol[i]) break; if(i>=N) { if(protocol[1]==1) return subtask2(); if(protocol[1]==2) return subtask3(); } return 0; }
#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...