ural 1242. Werewolf
1242. Werewolf
Memory limit: 64 MB
Input
Output
Samples
input | output |
---|---|
8 |
4 5 7 |
6 |
0 |
Problem Source: Ural State University Personal Programming Contest, March 1, 2003
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <deque>
#include <vector>
#include <queue>
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <ctime>
#include <iomanip>
using namespace std;
typedef long long LL;
typedef double DB;
#define For(i, s, t) for(int i = (s); i <= (t); i++)
#define Ford(i, s, t) for(int i = (s); i >= (t); i--)
#define Rep(i, t) for(int i = (0); i < (t); i++)
#define Repn(i, t) for(int i = ((t)-1); i >= (0); i--)
#define rep(i, x, t) for(int i = (x); i < (t); i++)
#define MIT (2147483647)
#define INF (1000000001)
#define MLL (1000000000000000001LL)
#define sz(x) ((int) (x).size())
#define clr(x, y) memset(x, y, sizeof(x))
#define puf push_front
#define pub push_back
#define pof pop_front
#define pob pop_back
#define ft first
#define sd second
#define mk make_pair
inline void SetIO(string Name)
{
string Input = Name+".in",
Output = Name+".out";
freopen(Input.c_str(), "r", stdin),
freopen(Output.c_str(), "w", stdout);
} inline bool Getint(int &Ret)
{
Ret = ;
char Ch = ' ';
bool Flag = ;
while(!(Ch >= '' && Ch <= ''))
{
if(Ch == 'B') Flag = ;
if(Flag == && Ch == 'D') break;
Ch = getchar();
}
if(Flag) return ;
while(Ch >= '' && Ch <= '')
{
Ret = Ret * + Ch - '';
Ch = getchar();
}
return ;
} const int N = ;
int n;
vector<int> Parent[N], Child[N], Ans;
bool Visit[N]; inline void Input()
{
scanf("%d", &n);
int x, y;
while(Getint(x))
{
Getint(y);
Parent[x].pub(y), Child[y].pub(x);
}
} inline void GoUp(int x)
{
Visit[x] = ;
int Length = sz(Parent[x]);
Rep(i, Length) GoUp(Parent[x][i]);
Parent[x].clear();
} inline void GoDown(int x)
{
Visit[x] = ;
int Length = sz(Child[x]);
Rep(i, Length) GoDown(Child[x][i]);
Child[x].clear();
} inline void Solve()
{
int x;
while(~scanf("%d", &x))
{
GoUp(x);
GoDown(x);
} For(i, , n)
if(!Visit[i]) Ans.pub(i);
if(sz(Ans))
{
Rep(i, sz(Ans)-) printf("%d ", Ans[i]);
printf("%d\n", Ans.back());
}
else puts("");
} int main()
{
#ifndef ONLINE_JUDGE
SetIO("A");
#endif
Input();
Solve();
return ;
}
ural 1242. Werewolf的更多相关文章
- URAL 1242 Werewolf(DFS)
Werewolf Time limit: 1.0 secondMemory limit: 64 MB Knife. Moonlit night. Rotten stump with a short b ...
- 1242. Werewolf(dfs)
1242 简单dfs 往孩子方向搜一遍 父母方向搜一遍 输入还搞什么字符串.. #include <iostream> #include<cstdio> #include< ...
- WereWolf项目 Postmortem
WereWolf项目 Postmortem (博客园的MarkDown编辑器好像有些问题,编号都显示1..) 设想和目标 我们的软件要解决什么问题?是否定义得很清楚?是否对典型用户和典型场景有清晰的描 ...
- Werewolf流程分析
werewolf大致流程 首先是房主创建房间,创建成功以后房主开启web socket连接. 其他成员加入房间,加入房间后新成员和老成员的游戏玩家列表都会更新,然后新成员也要开启web socket连 ...
- 后缀数组 POJ 3974 Palindrome && URAL 1297 Palindrome
题目链接 题意:求给定的字符串的最长回文子串 分析:做法是构造一个新的字符串是原字符串+反转后的原字符串(这样方便求两边回文的后缀的最长前缀),即newS = S + '$' + revS,枚举回文串 ...
- ural 2071. Juice Cocktails
2071. Juice Cocktails Time limit: 1.0 secondMemory limit: 64 MB Once n Denchiks come to the bar and ...
- ural 2073. Log Files
2073. Log Files Time limit: 1.0 secondMemory limit: 64 MB Nikolay has decided to become the best pro ...
- ural 2070. Interesting Numbers
2070. Interesting Numbers Time limit: 2.0 secondMemory limit: 64 MB Nikolay and Asya investigate int ...
- ural 2069. Hard Rock
2069. Hard Rock Time limit: 1.0 secondMemory limit: 64 MB Ilya is a frontman of the most famous rock ...
随机推荐
- Maya导入Unity的教程
原地址:http://www.cocoachina.com/gamedev/gameengine/2010/0601/1586.html 昨天已经发布了1Vr.Cn翻译的多维材质模型烘培入Unity ...
- Stanford机器学习---第九讲. 聚类
原文:http://blog.csdn.net/abcjennifer/article/details/7914952 本栏目(Machine learning)包括单参数的线性回归.多参数的线性回归 ...
- [官方教程] [ES4封装教程]1.使用 VMware Player 创建适合封装的虚拟机
[转载处,http://bbs.itiankong.com/] 前言: 首先要明确的一点,系统封装操作的源计算机一般为虚拟计算机(简称虚拟机.VM等),这也是为什么我们要在封装教程的第一章就专门学习虚 ...
- HLG2035广搜
Diablo Time Limit: 1000 MS Memory Limit: 65536 K Total Submit: 42(21 users) Total Accepted: 23(20 us ...
- HDOJ 1162
Eddy's picture Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) T ...
- HDOJ 1869
#include<stdio.h> ][]; #define inf 0xffffff; void floyed(int n) { int i,j,k; ;k<n;k++) { ;i ...
- python模拟浏览器保存Cookie进行会话
#! /usr/bin/env python # -*-coding:utf- -*- import urllib import urllib2 import cookielib class NetR ...
- 新建myeclipse工作空间需要的工作
接触了许多个项目,都挺大的,每次都需要配置,简单总结总结. 第一.右击项目,选择Text file encoding 第二.点击window-->preferences-->myeclip ...
- HDU 5793 A Boring Question (逆元+快速幂+费马小定理) ---2016杭电多校联合第六场
A Boring Question Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others ...
- Codeforces Round #321 (Div. 2)C(tree dfs)
题意:给出一棵树,共有n个节点,其中根节点是Kefa的家,叶子是restaurant,a[i]....a[n]表示i节点是否有猫,问:Kefa要去restaurant并且不能连续经过m个有猫的节点有多 ...