A1353 | [COCI-2016_2017-contest5]#3 Ronald
来源COCI
时间限制1s
内存限制128MB
通过 / 提交0/0
题目描述
There are N cities in one country that are connected with two-way air links. One crazy airline president, Ronald Krump, often changes the flight schedule. More precisely, every day he does the following:
● chooses one of the cities, ● introduces flights from that city towards all other cities where these flights do not currently exist, and at the same time cancels all existing flights from that city For instance, if from city 5 flights exist towards cities 1 and 2, but not towards cities 3 and 4, after Krump’s change, there will exist flights from city 5 towards cities 3 and 4, but not towards cities 1 and
2.
The citizens of this country are wondering if a day could come when the flight schedule will be complete. In other words, when between each two different cities a (direct) flight will exist.
Write a programme that will, based on the current flight schedule, determine whether it is possible to have a Complete Day, or whether this will never happen, no matter what moves Krump makes.
● chooses one of the cities, ● introduces flights from that city towards all other cities where these flights do not currently exist, and at the same time cancels all existing flights from that city For instance, if from city 5 flights exist towards cities 1 and 2, but not towards cities 3 and 4, after Krump’s change, there will exist flights from city 5 towards cities 3 and 4, but not towards cities 1 and
2.
The citizens of this country are wondering if a day could come when the flight schedule will be complete. In other words, when between each two different cities a (direct) flight will exist.
Write a programme that will, based on the current flight schedule, determine whether it is possible to have a Complete Day, or whether this will never happen, no matter what moves Krump makes.
输入格式
The first line of input contains the integer N (2 ≤ N ≤ 1000), the number of cities. The cities are labeled with numbers from 1 to N.
The second line contains the integer M (0 ≤ M < N*(N-1)/2), the number of current flights.
Each of the following M lines contains two different numbers, the labels of the cities that are currently connected.
The second line contains the integer M (0 ≤ M < N*(N-1)/2), the number of current flights.
Each of the following M lines contains two different numbers, the labels of the cities that are currently connected.
输出格式
The first and only line of output must contain DA (Croatian for "yes") or NE (Croatian for "no").
输入输出样例
输入 #1
2 0
输出 #1
DA
输入 #2
3 2 1 2 2 3
输出 #2
NE
输入 #3
4 2 1 3 2 4
输出 #3
DA
Clarification of the first test case: In the first step, Krump will introduce the (only possible) line 1-2.
Clarification of the third case: If Krump first chooses city 1, flights 1-2, 1-4 and 2-4 will exist. If he
then chooses city 3, the flight schedule will become complete.
Clarification of the third case: If Krump first chooses city 1, flights 1-2, 1-4 and 2-4 will exist. If he
then chooses city 3, the flight schedule will become complete.
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted