제출 #742218

#제출 시각아이디문제언어결과실행 시간메모리
742218MODDI친구 (IOI14_friend)C++14
0 / 100
1 ms340 KiB
#include "friend.h" //#include "grader.cpp" #include <bits/stdc++.h> #define ll long long #define pii pair<int,int> #define pll pair<ll,ll> #define pb push_back #define mp make_pair #define vi vector<int> using namespace std; bool find(int j, vector<vi>& g, vi& btoa, vi& vis) { if (btoa[j] == -1) return 1; vis[j] = 1; int di = btoa[j]; for (int e : g[di]) if (!vis[e] && find(e, g, btoa, vis)) { btoa[e] = di; return 1; } return 0; } int dfsMatching(vector<vi>& g, vi& btoa) { vi vis; for(int i = 0; i < g.size(); i++) { vis.assign(btoa.size(), 0); for (int j : g[i]) if (find(j, g, btoa, vis)) { btoa[j] = i; break; } } return (int)btoa.size() - (int)count(btoa.begin(), btoa.end(), -1); } vi cover(vector<vi>& g, int n, int m) { vi match(m, -1); int res = dfsMatching(g, match); vector<bool> lfound(n, true), seen(m); for (int it : match) if (it != -1) lfound[it] = false; vi q, cover; for(int i = 0; i < n; i++) if (lfound[i]) q.push_back(i); while (!q.empty()) { int i = q.back(); q.pop_back(); lfound[i] = 1; for (int e : g[i]) if (!seen[e] && match[e] != -1) { seen[e] = true; q.push_back(match[e]); } } for(int i = 0; i < n; i++) if (!lfound[i]) cover.push_back(i); for(int i = 0; i < m; i++) if (seen[i]) cover.push_back(n+i); return cover; } int findSample(int n,int confidence[],int host[],int protocol[]){ vector<vector<int>> g; for(int i = 1; i < n; i++){ if(protocol[i] == 0){ g[host[i]].pb(i); } else{ for(auto t : g[host[i]]) { g[t].pb(i); } } } return (n-(int)cover(g, n, g.size()).size()); }

컴파일 시 표준 에러 (stderr) 메시지

friend.cpp: In function 'int dfsMatching(std::vector<std::vector<int> >&, std::vector<int>&)':
friend.cpp:23:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   23 |  for(int i = 0; i < g.size(); i++) {
      |                 ~~^~~~~~~~~~
friend.cpp: In function 'std::vector<int> cover(std::vector<std::vector<int> >&, int, int)':
friend.cpp:35:6: warning: unused variable 'res' [-Wunused-variable]
   35 |  int res = dfsMatching(g, match);
      |      ^~~
#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...