大水题一道啊,几分钟切掉。

还是扩展域,每个点拆3个点,之间连边表示有关系(即捕食关系)。然后随便判定一下就好了,不难,毕竟NOI上古题目。

 #include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<queue>
#define dbg(x) cerr<<#x<<" = "<<x<<endl
#define ddbg(x,y) cerr<<#x<<" = "<<x<<" "<<#y<<" = "<<y<<endl
using namespace std;
typedef long long ll;
template<typename T>inline char MIN(T&A,T B){return A>B?A=B,:;}
template<typename T>inline char MAX(T&A,T B){return A<B?A=B,:;}
template<typename T>inline T _min(T A,T B){return A<B?A:B;}
template<typename T>inline T _max(T A,T B){return A>B?A:B;}
template<typename T>inline T read(T&x){
x=;int f=;char c;while(!isdigit(c=getchar()))if(c=='-')f=;
while(isdigit(c))x=x*+(c&),c=getchar();return f?x=-x:x;
}
const int N=+;
int fa[N<<],n,m,x,y,c,cnt;
inline int Get(int x){return fa[x]^x?fa[x]=Get(fa[x]):x;} int main(){//freopen("test.in","r",stdin);//freopen("test.out","w",stdout);
read(n),read(m);
for(register int i=;i<=n*;++i)fa[i]=i;
for(register int i=;i<=m;++i){
read(c),read(x),read(y);
if(x>n||y>n){++cnt;continue;}
if(c==){
if(Get(x)==Get(y+n)||Get(x)==Get(y+n+n)){++cnt;continue;}
fa[Get(x)]=Get(y),fa[Get(x+n)]=Get(y+n),fa[Get(x+n+n)]=Get(y+n+n);
}
else{
if(Get(x)==Get(y)||Get(x)==Get(y+n+n)){++cnt;continue;}
fa[Get(x)]=Get(y+n),fa[Get(x+n)]=Get(y+n+n),fa[Get(x+n+n)]=Get(y);
}
}
printf("%d\n",cnt);
return ;
}

最新文章

  1. Jass 技能模型定义(—):半人马酋长的反击光环
  2. android camera setMeteringArea详解
  3. opencv6.5-imgproc图像处理模块之轮廓
  4. Jenkins 报错:(pending—Waiting for next available executor)
  5. 什么是ORACLEASM
  6. How to get blob data using javascript XmlHttpRequest by sync
  7. 个人电脑配置FTP服务器,四张图搞定。项目需要,并自己写了个客户端实现下载和上传的功能!
  8. Spring与Quartz的整合实现定时任务调度
  9. C++标准转换运算符const_cast
  10. group by order by having
  11. CentOS系统、Jdk、Tomcat安装实战
  12. MATLAB快速注释方法
  13. CSS实现页面背景自动切换功能
  14. java输出菱形
  15. 【日常学习】【线性DP】codevs1044 拦截导弹题解
  16. 单点登录之CAS SSO从入门到精通(第三天)
  17. Database Administration Statements
  18. 莫烦tensorflow(9)-Save&amp;Restore
  19. Linux_CentOS-服务器搭建 &lt;三&gt; 补充
  20. HDU 3440 House Man(编号排序+线性差分约束跑最短路)

热门文章

  1. Android MarginLeft与MarginStart的差别
  2. Django--网页管理实例解析
  3. 浅谈iOS中MVVM的架构设计与团队协作【转载】
  4. HDU 2112 HDU Today(STL MAP + Djistra)
  5. linux中下载JDK 1.7
  6. js document.queryCommandState() 各个参数
  7. 800元组装一台3D打印机全教程流程
  8. .net调用存储过程详解(转载)
  9. Spring、Hibernate 数据不能插入到数据库问题解决
  10. 【题解】At2370 Piling Up