Thrall’s Dream 第四届山东省省赛 (直接暴力DFS)
题目链接:题目
AC代码:
#include<iostream>
#include<algorithm>
#include<vector>
#include<cstring>
#include<cstdio>
using namespace std;
const int N = ;
int m,n;
bool vis[N][N],vis1[N];
vector< int >mm[N];
void dfs(int m,int x)
{
if(mm[x].size()==) return;
for(int i=;i<mm[x].size();i++)
{
if(vis[m][mm[x][i]] == false)
{
vis[m][mm[x][i]]=true;
int t = mm[x][i];
dfs(m,t);
}
}
}
int main()
{
int T,cas =,x,y;
scanf("%d",&T);
while(T--)
{
scanf("%d %d",&m,&n);
for(int i=;i<=m;i++)
mm[i].clear();
for(int i=; i<n; i++)
{
scanf("%d %d",&x,&y);
mm[x].push_back(y);
}
memset(vis,false,sizeof(vis));
for(int i=;i<=m;i++)
vis[i][i] = true;
for(int i =;i<=m;i++) dfs(i,i);
bool flag = true;
for(int i=;i<=m;i++)
{
for(int j=;j<=m;j++)
{
if(vis[i][j] == false && vis[j][i] == false)
{
flag = false;
goto end;
}
}
}
end: if (flag) printf("Case %d: Kalimdor is just ahead\n",cas++);
else printf("Case %d: The Burning Shadow consume us all\n",cas++);
}
return ;
}
Thrall’s Dream 第四届山东省省赛 (直接暴力DFS)的更多相关文章
- sdut 2610:Boring Counting(第四届山东省省赛原题,划分树 + 二分)
Boring Counting Time Limit: 3000ms Memory limit: 65536K 有疑问?点这里^_^ 题目描述 In this problem you a ...
- sdut 2603:Rescue The Princess(第四届山东省省赛原题,计算几何,向量旋转 + 向量交点)
Rescue The Princess Time Limit: 1000ms Memory limit: 65536K 有疑问?点这里^_^ 题目描述 Several days ago, a b ...
- 山东省第四届ACM省赛
排名:http://acm.sdut.edu.cn/sd2012/2013.htm 解题报告:http://www.tuicool.com/articles/FnEZJb A.Rescue The P ...
- sdutoj 2604 Thrall’s Dream
http://acm.sdut.edu.cn/sdutoj/problem.php?action=showproblem&problemid=2604 Thrall’s Dream Time ...
- [原]sdut2624 Contest Print Server (大水+大坑)山东省第四届ACM省赛
本文出自:http://blog.csdn.net/svitter 原题:http://acm.sdut.edu.cn/sdutoj/problem.php?action=showproblem&am ...
- 2013年省赛I题 Thrall’s Dream
2013年省赛I题判断单向联通,用bfs剪枝:从小到大跑,如果遇到之前跑过的点(也就是编号小于当前点的点),就o(n)传递关系. bfs #include<iostream> #inclu ...
- [原]sdut2605 A^X mod P 山东省第四届ACM省赛(打表,快速幂模思想,哈希)
本文出自:http://blog.csdn.net/svitter 题意: f(x) = K, x = 1 f(x) = (a*f(x-1) + b)%m , x > 1 求出( A^(f(1) ...
- sdut 2416:Fruit Ninja II(第三届山东省省赛原题,数学题)
Fruit Ninja II Time Limit: 5000MS Memory limit: 65536K 题目描述 Have you ever played a popular game name ...
- "浪潮杯"第六届ACM山东省省赛山科场总结
从空间拷过来的.尽管已经过去一个月了.记忆犹新 也算是又一次拾起这个blog Just begin 看着一群群大牛还有队友男神的省赛总结都出了 我最终也耐不住寂寞 来做个流水账抒抒情好了 第一次省赛 ...
随机推荐
- tracepath 路由跟踪命令
[root@c1 scripts]# tracepath 100.2.4.144 (备注:linux系统) 1: c1.nulige.com (100.2.4.144) 0.047ms pmtu ...
- Vue使用中遇到问题汇总(二)
1.vue cli使用npm run dev报错cannot get / config/index.js里有两个环境:一个是build,一个dev. 在config/index.js里面修改,buil ...
- 开发 nodejs REST 个人感想
本来想拿 nodejs 做个 ip 查询小应用的,做的时候想着把基础弄好再做应用,没想到做着做着就变成 spring 了 可能太多数人觉得不知道怎么用,以后我会写详细点使用教程 个人感觉自己做出来的东 ...
- 阿里云64位centos6.3系统上编译安装redis
环境 系统:阿里云64位centos 6.3 [rao@AY~]$ cat /etc/issue CentOS release 6.3 (Final) Kernel \r on an \m [rao@ ...
- WPF使用ARCGIS App文件配置Cs后台文件
using System; using System.Collections.Generic; using System.Configuration; using System.Data; using ...
- PHP的抽象类、接口的区别和选择[转载]
区别: 1.对接口的使用是通过关键字implements.对抽象类的使用是通过关键字extends.当然接口也可以通过关键字extends继承. 2.接口中不可以声明成员变量(包括类静态变量),但是可 ...
- poj 2253 (dis最短路径)
Frogger Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 24979 Accepted: 8114 Descript ...
- Spring之替换Bean的返回结果,替换Bean的方法实例
Spring是一个非常强悍的框架+容器,其中有代理模式(动态代理模式)的极致体现.下面是两个比较让人感觉精彩的代码使用,重点关注main方法中的ClassPathXMlApplicationConte ...
- python版本管理--pyenv
python版本环境管理 下载依赖 yum install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readli ...
- Windows最强ssh客户端推荐 —— Bitvise SSH Client
原名Tunnelier,解除它是因为为了sshFQ,没想到它既有SSH Terminal,又集成SFTP,还能FQ,功能一应区全. 还支持pem证书,回想最初使用putty,还要把pem证书进行转换才 ...