Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
Register

## 什么并查集，dfs就可以过（注意输入内面狗子描述的是自身的时猴要特殊处理！因为这个wa了一次）

Posted by KatrineYang at 2016-08-21 02:59:19 on Problem 1291
```#include <iostream>
#include <stdio.h>
using namespace std;

int used[1004];

int dui, cuo;
int zong = 0;

void init(int N){
for(int i = 1; i <= N; i++) {
used[i] = 0;
}
zong = 0;
}

void dfs(int i, bool tag){
used[i] = tag?1:-1;
if(tag) dui++;
else cuo++;
for(int j = 0; j < adjNum[i]; j++){
bool t = (tag + adjTF[i][j])%2;
}
}
}

int main() {
while(1){
int N;
scanf("%d", &N);
if(N == 0) break;
init(N);
char fei1[32], fei2[4];
for(int i = 1; i <= N; i++){
int j;
char tf[15];
scanf("%s%d%s%s", fei1, &j, fei2, tf);
if(i != j){
if(tf[0] == 't'){
}
else{
}
}
else{
if(tf[0] == 't'){
}
else{
}
}
}
for(int i = 1; i <= N; i++){
if(used[i] != 0) continue;
dui = 0;
cuo = 0;
dfs(i, 1);
if(dui > cuo) zong += dui;
else zong += cuo;
}
bool ok = 1;
for(int i = 1; i <= N; i++){
for(int j = 0; j < adjNum[i]; j++){
ok = 0;
break;
}
ok = 0;
break;
}
}
}
if(ok){
printf("%d\n", zong);
}
else{
printf("Inconsistent\n");
}
}
return 0;
}
```

Followed by: