Submission #902973

#TimeUsernameProblemLanguageResultExecution timeMemory
902973Muhammad_AneeqFriend (IOI14_friend)C++17
27 / 100
1071 ms34484 KiB
#include <vector> #include <iostream> #include <set> #include "friend.h" using namespace std; int const N=2000; int ed[N][N]={}; int vis[N]={}; int ans=0; int nn; int val[N]={}; int cur[N]={}; void dfs(int i,int val1) { vis[i]=1; for (int j=0;j<nn;j++) cur[j]=cur[j]+(ed[i][j]==0); for (int j=0;j<nn;j++) { if (ed[i][j]&&!vis[j]&&cur[j]==0) dfs(j,val1+val[j]); } vis[i]=0; for (int j=0;j<nn;j++) cur[j]=cur[j]-(ed[i][j]==0); ans=max(ans,val1); } int findSample(int n,int confidence[],int host[],int protocol[]) { nn=n; for (int i=0;i<n;i++) val[i]=confidence[i]; for (int i=0;i<n;i++) for (int j=0;j<n;j++) ed[i][j]=1; set<int>s; for (int i=1;i<n;i++) { s.insert(protocol[i]); if (protocol[i]==0) ed[i][host[i]]=ed[host[i]][i]=0; else if (protocol[i]==1) { for (int j=0;j<n;j++) { if (ed[host[i]][j]==0) ed[i][j]=ed[j][i]=0; } } else { ed[i][host[i]]=ed[host[i]][i]=0; for (int j=0;j<n;j++) { if (ed[host[i]][j]==0) ed[i][j]=ed[j][i]=0; } } } if (s.size()==1&&*begin(s)==1) { int ans=0; for (int i=0;i<n;i++) ans+=val[i]; return ans; } for (int i=0;i<n;i++) dfs(i,val[i]); return ans; }

Compilation message (stderr)

friend.cpp: In function 'int findSample(int, int*, int*, int*)':
friend.cpp:33:2: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   33 |  for (int i=0;i<n;i++)
      |  ^~~
friend.cpp:36:3: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   36 |   set<int>s;
      |   ^~~
#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...