记录编号 |
98733 |
评测结果 |
AAAAAAAAAA |
题目名称 |
[HAOI 2006]受欢迎的牛 |
最终得分 |
100 |
用户昵称 |
LuciFer_T-J |
是否通过 |
通过 |
代码语言 |
C++ |
运行时间 |
0.041 s |
提交时间 |
2014-04-24 15:31:56 |
内存使用 |
1.13 MiB |
显示代码纯文本
#include<cstring>
#include<iostream>
#include<cstdio>
using namespace std;
#define __________________ 10005
#define ___________________ 50005
struct node{
int __________, ___________;
}________________[___________________];
int _________________[__________________],____[___________________];
int _[__________________],______[__________________],_____[__________________],___[__________________],__[__________________];
bool ____________________[__________________];
int ______________;
char _______________;
int n,m,s,_______,___s,________,_________;
void _____________(int __________,int ___________){
________________[++s].__________=__________;
________________[s].___________=___________;
____[s]=_________________[__________];
_________________[__________]=s;
}
void ____________(int x){
int i;
_______++;
_[x]=______[x]=_______;
_____[++________]=x;
____________________[x]=1;
for (i=_________________[x];i;i=____[i]){
if (!_[________________[i].___________]){
____________(________________[i].___________);
______[x]=min(______[x],______[________________[i].___________]);
}
else{
if (____________________[x]){
______[x]=min(______[x],_[________________[i].___________]);
}
}
}
if (______[x]==_[x]){
___s++;
while (_____[________+1]!=x){
___[_____[________]]=___s;
__[___s]++;
____________________[_____[________]]=0;
________--;
}
}
}
void _____________________(){
int i;
memset(____________________,1,sizeof(____________________));
for (i=1;i<=m;i++){
if (___[________________[i].__________]==___[________________[i].___________]) continue;
____________________[___[________________[i].__________]]=0;
}
}
int ______________________(){
while (!isdigit(_______________=getchar()));
______________=_______________-'0';
while (isdigit(_______________=getchar())){
______________=______________*10+_______________-'0';
}
return ______________;
}
int main(){
freopen("cow.in","r",stdin);
freopen("cow.out","w",stdout);
int i,__________,___________;
n=______________________();
m=______________________();
s=0;
for (i=1;i<=m;i++){
__________=______________________();
___________=______________________();
_____________(__________,___________);
}
_______=0;
________=0;
___s=0;
for (i=1;i<=n;i++){
if (_[i]) continue;
____________(i);
}
_____________________();
_________=0;
for (i=1;i<=___s;i++){
if (____________________[i]){
if (_________) {
cout<<0<<endl;
return 0;
}
_________=__[i];
}
}
cout<<_________<<endl;
return 0;
}