Submission #23701

#TimeUsernameProblemLanguageResultExecution timeMemory
23701HiasatFriend (IOI14_friend)C++14
0 / 100
0 ms3216 KiB
#include "friend.h" #include <bits/stdc++.h> using namespace std; vector<int> adj[1001]; bool vis[1001]; int f[2]; void dfs(int u , int color){ if(vis[u]) return; vis[u] = 1; f[color]++; for (int i = 0; i < adj[u].size(); ++i){ dfs(adj[u][i],!color); } } int findSample(int n,int confidence[],int host[],int protocol[]){ for(int i = 1 ; i <= n; i++){ if(protocol[i] == 1){ adj[host[i]].push_back(i); adj[i].push_back(host[i]); } if(protocol[i] == 2){ for(int j = 0 ; j < adj[host[i]].size();j++){ int v = adj[host[i]][j]; adj[v].push_back(i); adj[i].push_back(v); } } } int ans = 0; for (int i = 0; i < n; ++i){ if(vis[i]) continue; memset(f,0,sizeof f); dfs(i,0); ans += max(f[0],f[1]); } return ans; }

Compilation message (stderr)

friend.cpp: In function 'void dfs(int, int)':
friend.cpp:17:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for (int i = 0; i < adj[u].size(); ++i){
                    ^
friend.cpp: In function 'int findSample(int, int*, int*, int*)':
friend.cpp:28:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    for(int j = 0 ; j < adj[host[i]].size();j++){
                      ^
#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...