Submission #782024

#TimeUsernameProblemLanguageResultExecution timeMemory
782024I_Love_EliskaM_Friend (IOI14_friend)C++14
27 / 100
20 ms2628 KiB
#include "friend.h" #include <bits/stdc++.h> using namespace std; #define forn(i,n) for(int i=0;i<n;++i) #define pb push_back #define all(x) x.begin(),x.end() #define pi pair<int,int> #define f first #define s second using ll = long long; const int inf=1e9; const int N=1e3+5; int adj[N][N]; int vis[N]; vector<int> g[N]; int c[N]; int a[N]; int dfs(int u) { int r=a[u]; vis[u]=1; forn(i,N) if (adj[u][i]) { if (vis[i]) continue; c[i]=c[u]^1; r+=dfs(i); } return r; } int sum(int u) { int r=c[u]*a[u]; vis[u]=2; forn(i,N) if (adj[u][i]) { if (vis[i]==2) continue; r+=sum(i); } } int findSample(int n, int c[], int h[], int p[]) { if (n>1000) return 0; forn(i,n) a[i]=c[i]; if (n<=10) { for (int i=1; i<n; ++i) { if (p[i]) { forn(j,n) if (adj[h[i]][j]) adj[i][j]=adj[j][i]=1; } if (p[i]%2==0) { adj[h[i]][i]=adj[i][h[i]]=1; } } int ans=0; forn(mask,1<<n) { vector<int> v; forn(i,n) if ((mask>>i)&1) v.pb(i); int f=0, s=0; for(auto&x:v) for(auto&y:v) f|=adj[x][y]; for(auto&x:v) s+=a[x]; if (!f) ans=max(ans,s); } return ans; } int z; z=1; for (int i=1; i<n; ++i) z&=p[i]==1; if (z) { int s=0; forn(i,n) s+=a[i]; return s; } z=1; for (int i=1; i<n; ++i) z&=p[i]==2; if (z) { int s=0; forn(i,n) s=max(s,a[i]); return s; } int ans=0; forn(i,n) { if (vis[i]) continue; int sz=dfs(i); int x=sum(i); ans+=max(sz-x,x); } return ans; }

Compilation message (stderr)

friend.cpp: In function 'int sum(int)':
friend.cpp:38:1: warning: no return statement in function returning non-void [-Wreturn-type]
   38 | }
      | ^
#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...