L2-010. 排座位

参考博客

 #include<iostream>
#include<math.h>
using namespace std;
int a[];
int map[][];
int find(int t)
{
if(t!=a[t])
{
a[t]=find(a[t]);
}
return a[t];
}
int main()
{
int n,m,k,i;
cin>>n>>m>>k;
for(i=;i<=n;i++)
a[i]=i;
int x,y,z;
for(i=;i<=m;i++)
{
cin>>x>>y>>z;
map[x][y]=map[y][x]=z;
if(z==)
{
x=find(x);
y=find(y);
if(x!=y)
a[x]=y;
}
}
int t1,t2;
for(i=;i<=k;i++)
{
cin>>t1>>t2;
if(map[t1][t2]==)
{
cout<<"No problem"<<endl;
}
else if(map[t1][t2]==-)
{
if(find(t1)==find(t2))
cout<<"OK but..."<<endl;
else
cout<<"No way"<<endl;
}
else
{
cout<<"OK"<<endl;
}
}
}

最新文章

  1. c++字符串
  2. 上架到AppStore?第一次上架之路
  3. JS 关于(function( window, undefined ) {})(window)写法的理解
  4. javascript中比较数字大小
  5. 初识Winform , 还好没喜欢上控制台
  6. 另一种遍历Map的方式: Map.Entry 和 Map.entrySet()
  7. HDU5802-windows 10-dfs+贪心
  8. 淘宝(阿里百川)手机客户端开发日记第六篇 Service详解(六)
  9. 《JavaScript模式》第1章 简介
  10. compass(sass)+seajs+frozenui+frozenjs+svn主干分支
  11. java学习:用反射构造bean
  12. 如何学会web前端开发
  13. 无法在People Picker中选择用户
  14. docker managed volume - 每天5分钟玩转 Docker 容器技术(40)
  15. poj 3264 &amp; poj 3468(线段树)
  16. Linux SHELL中sh和bash的区别
  17. Linux IO 模型
  18. Dash VS Underscore
  19. gi常用命令
  20. git install

热门文章

  1. Objective-C不能以new开头命名属性
  2. lvs 初始 第一章
  3. vue 2.0 使用replace时要点击路由多次才能返回
  4. Cocos Creator 使用protobufjs
  5. [easyUI] datagrid 数据格 可以进行分页
  6. guxh的python笔记二:函数基础
  7. python实现http get请求
  8. 『TensorFlow』读书笔记_Inception_V3_上
  9. vs2013+qt5.3.2+pcl1.8.0+osg2.3开发环境配置
  10. 单点登录系统实现基于SpringBoot