제출 #430660

#제출 시각아이디문제언어결과실행 시간메모리
430660Rouge_Hugo친구 (IOI14_friend)C++14
0 / 100
1 ms332 KiB
#include "friend.h" #include<bits/stdc++.h> #define ll long long #define fi first #define se second #define pb push_back using namespace std; const int N=1009; vector<int>v[N]; int vis[N],a[N];int re=0,al=0; void dfs(int x,int z) { if(vis[x]!=-1&&vis[x]!=z)while(1)re++; if(vis[x]!=-1)return; vis[x]=z;if(z)re++; al++; for(auto it:v[x]) { // if(vis[it]!=-1)continue; dfs(it,1-z); } } int findSample(int n,int c[],int h[],int p[]){ memset(vis,-1,sizeof vis); for(int i=1;i<n;i++) { if(p[i]==0){ v[h[i]].pb(i); v[i].pb(h[i]);} else { for(auto it:v[h[i]]){ v[i].pb(it); v[it].pb(i); } } } int mx=0; for(int i=0;i<n;i++)a[i]=c[i]; for(int i=0;i<n;i++) { if(vis[i]!=-1)continue; re=0;al=0; dfs(i,1); mx+=max(re,al-re); } return mx; } /* 5 1 100 1 1 100 0 0 0 0 1 1 2 2 */
#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...