Call to your teacher
链接:https://www.nowcoder.net/acm/contest/76/F
来源:牛客网
空间限制:C/C++ 32768K,其他语言65536K
64bit IO Format: %lld
题目描述
输入描述:
存在多组测试样例
每组样例的第一行分别是两个整数n(1<n<=50),m(1<m<=2000),n是在题目当中出现的人数,其中你的序号是1号,实验室老师的序号是n。
接下来的m行,每行有两个整数x(1<=x<=n),y(1<=y<=n),代表x有y的电话号码。
输出描述:
对于每组测试样例,如果你最终能联系到老师,输出“Yes”,否则输出“No”。
输入例子:
5 5
1 3
2 3
3 4
2 4
4 5
输出例子:
Yes
-->
输入
5 5
1 3
2 3
3 4
2 4
4 5
输出
Yes
输入
4 3
1 2
2 3
4 1
输出
No
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
using namespace std;
int e[][];
int main()
{
int n, m;
while (cin >> n >> m)
{
int i, j;
for (i = ; i <= n; i++)
{
for (j = ; j <= m; j++)
{
if (i == j) e[i][j] = ;
else
e[i][j] = ;
}
}
for (i = ; i <= m; i++)
{
int x, y;
cin >> x >> y;
e[x][y] = ;
}
int k;
for (k = ; k <= n; k++)
{
for (i = ; i <= n; i++)
{
for (j = ; j <= n; j++)
{
if (e[i][j] == )
{
e[i][j] = (e[i][k] == && e[k][j] == );
}
}
}
}
if (e[][n]) cout << "Yes" << endl;
else cout << "No" << endl;
}
return ;
}
Call to your teacher的更多相关文章
- 设有一数据库,包括四个表:学生表(Student)、课程表(Course)、成绩表(Score)以及教师信息表(Teacher)。
一. 设有一数据库,包括四个表:学生表(Student).课程表(Course).成绩表(Score)以及教师信息表(Teacher).四个表的结构分别如表1-1的表(一)~表( ...
- 【英语学习】2016.09.11 Culture Insider: Teacher's Day in ancient China
Culture Insider: Teacher's Day in ancient China 2016-09-10 CHINADAILY Today is the 32nd Chinese Te ...
- 对teacher表进行增加,删除,修改
<%@page import="java.text.SimpleDateFormat"%> <%@ page language="java" ...
- 超强语感训练文章(Provided by Rocky teacher Prince)
Content: Class1 My name is Prince Class2 Welcome to our hotel Class3 We’re not afraid of problems Cl ...
- hdu 5762 Teacher Bo 曼哈顿路径
Teacher Bo Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others)Tota ...
- Oracle数据库作业-6 29、查询选修编号为“3-105“课程且成绩至少高于选修编号为“3-245”的同学的Cno、Sno和Degree,并按Degree从高到低次序排序。 select tname,prof from teacher where depart = '计算机系' and prof not in ( select prof from teacher where depart 。
29.查询选修编号为"3-105"课程且成绩至少高于选修编号为"3-245"的同学的Cno.Sno和Degree,并按Degree从高到低次序排序. selec ...
- HDU 5762 Teacher Bo
Teacher Bo Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others)Tota ...
- HDU 5762 Teacher Bo (暴力)
Teacher Bo 题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5762 Description Teacher BoBo is a geogra ...
- 2014-11-9------- 设有一数据库,包括四个表:学生表(Student)、课程表(Course)、成绩表(Score)以及教师信息表(Teacher)。
一. 设有一数据库,包括四个表:学生表(Student).课程表(Course).成绩表(Score)以及教师信息表(Teacher).四个表的结构分别如表1-1的表(一)~表( ...
- Good Teacher(模拟)
Good Teacher Time Limit:1000MS Memory Limit:0KB 64bit IO Format:%lld & %llu Submit Statu ...
随机推荐
- Tinkoff Challenge - Elimination Round B. Igor and his way to work(dfs+优化)
http://codeforces.com/contest/793/problem/B 题意:一个地图,有起点和终点还有障碍点,求从起点出发到达终点,经过的路径上转弯次数是否能不超过2. 思路: 直接 ...
- Android -- 怎么发出和接收广播, Broadcast, 电话拨号拦截,短信拦截
1. 发送广播 使用以下三个API可以发送广播 public void click(View view){ Intent intent = new Intent(); intent.setAction ...
- Android 引用资源
比如在 strings.xml 中找到的 Hello world!字符串,我们有两种方式可以引用它: 1. 在代码中通过 R.string.hello_world 可以获得该字符串的引用: 2. 在 ...
- mongodb 用户点赞功能理论实现[转载]
在 posts(文章) 集合中储存对该文章点赞的用户的 _id 的数组,例如: // posts { _id: ObjectID('4e7020cb7cac81af7136236b'), users_ ...
- Python——列表表达式
https://www.cnblogs.com/xuyuanyuan123/p/6718403.html
- 【原创】遇到:Invalid layout of java.lang.String at value 这样的问题,该怎么办呢?
Invalid layout of java.lang.String at value## A fatal error has been detected by the Java Runtime En ...
- 51nod-1420-贪心
1420 数袋鼠好有趣 题目来源: CodeForces 基准时间限制:1 秒 空间限制:131072 KB 分值: 40 难度:4级算法题 收藏 关注 有n只袋鼠.每只袋鼠的大小用一个整数表示 ...
- prim和kruskal比较
推荐:http://squirrelrao.iteye.com/blog/1044867 http://www.cnblogs.com/xwdreamer/archive/2011/06/16/22 ...
- iptables Configuration
iptables usage: Add Rules: iptables -I INPUT -p tcp --dport -j ACCEPT iptables -I INPUT -p tcp --dpo ...
- ES6学习一 JS语言增强篇
一 背景 JavaScript经过二十来年年的发展,由最初简单的交互脚本语言,发展到今天的富客户端交互,后端服务器处理,跨平台(Native),以及小程序等等的应用.JS的角色越来越重要,处理场景越来 ...