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 ...
随机推荐
- Filter实现session超时自动跳转到login页,超过试用期不许登录
新建一个过滤器 package com.autumn.filter; import com.autumn.pojo.Users; import javax.servlet.*; import java ...
- Leetcode 23.Merge Two Sorted Lists Merge K Sorted Lists
Merge Two Sorted Lists Merge two sorted linked lists and return it as a new list. The new list shoul ...
- linux yum安装lsof命令
[root@ITC-MCC ~]# yum install lsof[USM] permission denied^C[root@ITC-MCC ~]# [root@ITC-MCC ~]# [root ...
- 处理EXCEL11问题
程序原本是好使的,但是自从卸载OFFICE11而安装14后,程序无法启动. 重新安装2003 ,然后,删除原引用 Microsoft.Office.Interop.Excel,然后添加引用,浏览,找到 ...
- VM虚拟机安装的XP如何全屏
首先安装install VMwear Tools..,如图:
- Linux vi编辑器的使用
vi是Visual Interface的简称,它是Linux/Unix下的文本编辑器,例如你想编辑文件english.txt,则你可以在终端下输入 vi english.txt命令,然后就进入了编辑界 ...
- [转载]字符串匹配的Boyer-Moore算法
作者: 阮一峰 日期: 2013年5月 3日 上一篇文章,我介绍了KMP算法. 但是,它并不是效率最高的算法,实际采用并不多.各种文本编辑器的"查找"功能(Ctrl+F),大多采用 ...
- 050——VUE中使用js库控制vue过渡动作
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- Cobbler自动化安装
# Cobbler自动化安装 [Cobbler官网](http://cobbler.github.io) ![](/Users/wanyongzhen/Library/Containers/com.t ...
- easyui panel自适应浏览器宽度
一.目标效果: 当浏览器窗口大小改变时.panel宽度始终为浏览器宽度的50%,panel高度则根据其中内容的多少而变化,横向竖向滚动条皆不出现.且不需要重新刷新浏览器或者其他js代码 兼容:chro ...