题意:求01成立。

并查集维护,记录一个变量判断决策。

#include<bits/stdc++.h>
using namespace std;
#define int long long
const int maxn = 4000010;
int f[maxn];
inline int find(int x){
return x == f[x]?x : f[x] = find(f[x]);
}
signed main()
{
ios::sync_with_stdio(false);
int T;
cin >> T;
while(T--){
int n,m;
cin >> n >> m;
int tag = (m < n + 2);
for(int i = 1;i <= (n << 1); ++i){
f[i] = i;
}
for(int i = 1;i <= m; ++i){
int x,y;
cin >> x >> y;
f[find(x)] = find(y + n);
f[find(y)] = find(x + n);
}
for(int i = 1;i <= n && tag; ++i){
tag &= (find(i) != find(i + n));
}
if(tag) puts("YES");
else puts("NO");
}
return 0;
}

最新文章

  1. HTML2
  2. 博弈SG
  3. python中文编码
  4. magento app开发遇到的问题及解决
  5. C#中判断一个集合是另外一个集合的子集
  6. ADO.NET事务处理,初始回调函数,多张表的数据在同一个DataGridView中展示
  7. hdu1874 畅通工程续
  8. SQL 跨服务器数据库增、删、改、查(二)
  9. MySQL查询本周、上周、本月、上个月份数据的sql代码(转)
  10. CentOS_5.6下使用cmake编译MySQL_5.5.11
  11. k8s使用helm打包chart并上传到腾讯云TencentHub
  12. 【译】.NET 跨平台界面框架和为什么你首先要考虑再三
  13. chm提取
  14. linux下apache中httpd.conf的ServerAdmin 是设置的什么?
  15. Gitlab Runner的使用(涵盖gitlab-page)
  16. uva11383 转化为 二分图匹配
  17. FormValidator表单验证
  18. Pi 实现VLC网络视频监控
  19. json转List、Map
  20. django-settings.py配置

热门文章

  1. 使用JMeter进行http压力测试
  2. 深度探索C++对象模型读书笔记-第六章执行期语意学
  3. PHP算法之最接近的三数之和
  4. 8.Struts2拦截器
  5. select 可输入的下拉框
  6. 【Nginx】Nginx配置
  7. 暴力模拟——cf988E
  8. paper 16 : 计算机视觉领域博客资源
  9. JSP/Servlet笔记
  10. LeetCode 744. Find Smallest Letter Greater Than Target (寻找比目标字母大的最小字母)