19BCS2626 Crab Graph
19BCS2626 Crab Graph
exactly K edges which join the head to each of the feet.( 1 <= K <= T, where T is given)
Given an undirected graph, you have to find in it some vertex-disjoint subgraphs where each one
is a crab . The goal is to select those crabs in such a way that the total number of vertices covered
by them is maximized.
CODE-
#include <cmath>
#include <cstdio>
#include <vector>
#include <queue>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
#define source (0)
#define target (1)
int capacity[300][300];
int flow[300][300];
while (true) {
bool visited[300];
memset(visited, 0 , sizeof(visited));
int parent[300];
queue<int> bfs;
bfs.push(s);
visited[s] = true;
parent[s] = -1;
while (!bfs.empty()) {
int curr = bfs.front();
bfs.pop();
for (int i = 0; i < n; ++i) {
if (!visited[i] && capacity[curr][i] > flow[curr][i] -
flow[i][curr]) {
bfs.push(i);
parent[i] = curr;
visited[i] = true;
}
}
}
if (!visited[t]) { break; }
int main() {
/* Enter your code here. Read input from STDIN. Print output to STD
OUT */
int C;
cin >> C;
while (C--) {
memset(capacity, 0, sizeof(capacity));
int N, T, M;
cin >> N >> T >> M;
}
return 0;
}
OUTPUT: