ACM: 动态规划题 poj&nb…
来源:互联网 发布:金山tw域名遭抢注 编辑:程序博客网 时间:2024/06/05 21:01
Description
everyone belongs to one of the teams;
every team has at least one member;
every person in the team knows every other person in histeam;
teams are as close in their sizes as possible.
This task may have many solutions. You are to find and output anysolution, or to report that the solution does not exist.
Input
The first line in the input file contains a single integer number N(2 <= N <= 100) - the total number ofpersons to divide into teams, followed by N lines - one line perperson in ascending order of their identifiers. Each line containsthe list of distinct numbers Aij (1 <= Aij<= N, Aij != i) separated by spaces. The listrepresents identifiers of persons that ith person knows. The listis terminated by 0.
Output
Sample Input
5
2 3 5 0
1 4 5 3 0
1 2 5 0
1 2 3 0
4 3 2 1 0
Sample Output
3 1 3 5
2 2 4
题意: 现在要你将n个人分配到2个组里面, 已经给出每人的相识关系, 满足下列要求:
解题思路:
代码:
#include <cstdio>
#include <iostream>
#include <cstring>
using namespace std;
#define MAX 105
int n, C;
int num[MAX][2], p[MAX][2][MAX], color[MAX], path[MAX][MAX];
bool dp[MAX][MAX], g[MAX][MAX];
int count; //连通分量的个数
void read_graph()
{
}
bool dfs(int u) //二分染色
{
}
int DP()
{
}
void print_path()
{
}
int main()
{
//
end:;
}
- ACM: 动态规划题 poj&nb…
- ACM: 动态规划题 poj&nb…
- ACM: 动态规划题 poj&nb…
- ACM: 动态规划题 poj&nb…
- ACM: 动态规划题 poj&nb…
- ACM: 动态规划题 poj&nb…
- ACM: 动态规划题 poj&nb…
- ACM: 极其简单题 uva&nb…
- ACM: dp动态规划题(难) poj 3267 …
- ACM: dp题(动态规划) poj 2151 (d…
- ACM: 树状DP 动态规划题 poj 1463 …
- ACM: LA 3266 -&nb…
- ACM: 简单动态规划题 poj 2955
- ACM: 动态规划题 poj 2241
- ACM: 动态规划题 poj 1054
- ACM: 动态规划题 poj 2948
- ACM: 动态规划题 poj 1925
- ACM: 动态规划题 poj 3034
- windows.h
- ACM: 动态规划题 poj 2057 树状DP
- ACM: 动态规划题 poj 1947
- ACM: 动态规划题 poj 2486
- ACM: 动态规划题 poj 3140
- ACM: 动态规划题 poj&nb…
- ACM: 动态规划题 poj 1192 树形DP
- ACM: 动态规划题 poj 3659
- 动态规划: 经典0-1背包问题 (转)
- ACM: 动态规划题 poj&nb…
- ACM: 动态规划题 poj 3211 背包变…
- (OK)(OK) Fedora23——NS3(MANETs)——Docker(busybox)——genymotion(android)——All is OK
- ACM: 动态规划题 poj&nb…
- ACM: 动态规划题 poj 3093 0-1背包