题意:给出一些仰慕的关系,问有没有同性恋。
思路:给图染色,判断是不是二分图就可以。
#include<stdio.h>
#include<string.h>
const int N=2100;
int head[N],color[N],num,flag;
struct edge
{
int st,ed,next;
}e[N*1000];
void addedge(int x,int y)
{
e[num].st=x;e[num].ed=y;e[num].next=head[x];head[x]=num++;
e[num].st=y;e[num].ed=x;e[num].next=head[y];head[y]=num++;
}
void judge(int u)
{
int i,v;
for(i=head[u];i!=-1;i=e[i].next)
{
v=e[i].ed;
if(color[v]==-1)
{
color[v......
阅读全文