2833 奇怪的梦境

时间限制: 1 s
空间限制: 128000 KB
题目等级 : 黄金 Gold
 
 
 
 
题目描述 Description

Aiden陷入了一个奇怪的梦境:他被困在一个小房子中,墙上有很多按钮,还有一个屏幕,上面显示了一些信息。屏幕上说,要将所有按钮都按下才能出去,而又给出了一些信息,说明了某个按钮只能在另一个按钮按下之后才能按下,而没有被提及的按钮则可以在任何时候按下。可是Aiden发现屏幕上所给信息似乎有矛盾,请你来帮忙判断。

输入描述 Input Description

第一行,两个数N,M,表示有编号为1...N这N个按钮,屏幕上有M条信息。

接下来的M行,每行两个数ai,bi,表示bi按钮要在ai之后按下。所给信息可能有重复,保证ai≠bi。

输出描述 Output Description

若按钮能全部按下,则输出“o(∩_∩)o”。

若不能,第一行输出“T_T”,第二行输出因信息有矛盾而无法确认按下顺序的按钮的个数。输出不包括引号。

样例输入 Sample Input

3 3

1 2

2 3

3 2

样例输出 Sample Output

T_T

2

数据范围及提示 Data Size & Hint

对于30%的数据,保证0<N≤100。

对于50%的数据,保证0<N≤2000。

对于70%的数据,保证0<N≤5000。

对于100%的数据,保证0<N≤10000,0<M≤2.5N。

分类标签 Tags 点此展开

#include<iostream>
#include<cstdio>
#include<cstring>
#include<stack>
using namespace std;
struct node
{
int u;
int v;
int w;
int next;
}edge[];
int head[];
int num=;
int rudu[];
stack<int>s;
int main()
{
int n,m;
scanf("%d%d",&n,&m);
for(int i=;i<=n;i++)head[i]=-;
for(int i=;i<=m;i++)
{
scanf("%d%d",&edge[num].u,&edge[num].v);
edge[num].next=head[edge[num].u];
rudu[edge[num].v]++;
head[edge[num].u]=num++;
}
for(int i=;i<=n;i++)
{
if(rudu[i]==)
s.push(i);
}
int tot=;
while(s.size()!=)
{
int p=s.top();
s.pop();
for(int i=head[p];i!=-;i=edge[i].next)
{
rudu[edge[i].v]--;
if(rudu[edge[i].v]==)
{
s.push(edge[i].v);
tot++;
}
}
}
if(tot==n-)printf("o(∩_∩)o");
else
{
printf("T_T\n");
for(int i=;i<=n;i++)
{
if(rudu[i]!=)
{
printf("%d",i);
return ;
}
}
//printf("%d",tot);
}
return ;
}

2833 奇怪的梦境 未AC的更多相关文章

  1. 【CODEVS】2833 奇怪的梦境

    2833 奇怪的梦境 时间限制: 1 s 空间限制: 128000 KB 题目等级 : 黄金 Gold 题目描述 Description Aiden陷入了一个奇怪的梦境:他被困在一个小房子中,墙上有很 ...

  2. CODEVS——T 2833 奇怪的梦境

    http://codevs.cn/problem/2833/  时间限制: 1 s  空间限制: 128000 KB  题目等级 : 黄金 Gold 题解  查看运行结果     题目描述 Descr ...

  3. Codevs 2833 奇怪的梦境

    时间限制: 1 s  空间限制: 128000 KB  题目等级 : 黄金 Gold     题目描述 Description Aiden陷入了一个奇怪的梦境:他被困在一个小房子中,墙上有很多按钮,还 ...

  4. 【拓扑排序】CODEVS 2833 奇怪的梦境

    拓扑排序模板. #include<cstdio> #include<vector> #include<stack> using namespace std; #de ...

  5. codevs2833 奇怪的梦境

    2833 奇怪的梦境  时间限制: 1 s  空间限制: 128000 KB  题目等级 : 黄金 Gold 题解       题目描述 Description Aiden陷入了一个奇怪的梦境:他被困 ...

  6. codevs2833 奇怪的梦境 x

    2833 奇怪的梦境  时间限制: 1 s  空间限制: 128000 KB  题目等级 : 黄金 Gold   题目描述 Description Aiden陷入了一个奇怪的梦境:他被困在一个小房子中 ...

  7. 奇怪的梦境(codevs 2833)

    题目描述 Description Aiden陷入了一个奇怪的梦境:他被困在一个小房子中,墙上有很多按钮,还有一个屏幕,上面显示了一些信息.屏幕上说,要将所有按钮都按下才能出去,而又给出了一些信息,说明 ...

  8. 九度OJ 1016 火星A + B 未AC版,整型存储不下

    #include <iostream> #include <string.h> #include <sstream> #include <math.h> ...

  9. Poj 1755Triathlon 未Ac,先mark

    地址:http://poj.org/problem?id=1755 题目: Triathlon Time Limit: 1000MS   Memory Limit: 10000K Total Subm ...

随机推荐

  1. shell监测磁盘使用并发送邮件

    linux sendEmail工具的安装使用    1.下载文件 #wget  http://files.cnblogs.com/files/sunziying/sendEmail-v1.56.tar ...

  2. #425[div2]

    A 签到 #include<bits/stdc++.h> using namespace std; typedef long long ll; int main(){ ll n,k; ci ...

  3. ADT-23.0.2百度网盘下载地址

    最近 Google 被墙 http://download.csdn.net/download/wentai2009/7736389

  4. redis系列:主从复制

    1 简介 这篇文章主要讲述Redis的主从复制功能.会依次从环境搭建.功能测试和原理分析几个方面进行介绍. 2 准备工作 服务器架构图如下 启动主服务器101,使用info replication命令 ...

  5. win7 失去焦点解决方案

    将HKEY_CURRENT_USER\Control Panel\Desktop中的ForegroundLockTimeout的选项,改成十进制的200000毫秒或者十六进制30d40. 参考链接: ...

  6. 通过Python调用Spice-gtk

    序言 通过Virt Manager研究学习Spice gtk的Python方法 你将学到什么 Virt Manager研究 显示代码定位 首先我们使用Virt Manager来观察桌面连接窗口 然后我 ...

  7. [WIP]laravel 入门

    创建: 2019/06/20 安装    composer brew install composer  laravel composer global require "laravel/i ...

  8. jQuery之ajax() 参数

  9. svn图标修复

    https://blog.csdn.net/doubleface999/article/details/55798736 前一阵用上了win8,装了最新版本的Tortoise SVN,但发现文件夹和文 ...

  10. C.0689-The 2019 ICPC China Shaanxi Provincial Programming Contest

    We call a string as a 0689-string if this string only consists of digits '0', '6', '8' and '9'. Give ...