题目链接:Brexit

vector的使用(vector存边),巧用queue,相当于Bfs

 /* */
# include <iostream>
# include <cstdio>
# include <cstring>
# include <string>
# include <memory>
# include <cstdlib>
# include <cmath>
# include <climits>
# include <cctype>
# include <cassert>
# include <utility>
# include <deque>
# include <queue>
# include <stack>
# include <vector>
# include <bitset>
# include <set>
# include <map>
# include <functional>
# include <algorithm>
using namespace std;
 
# define lson l,m,rt<<
# define rson m+,r,rt<<|
# define lowbit(x)(x&(-x))
# define lcm(a,b)(a*b/__gcd(a,b))
typedef long long ll;
const ll mod=1e9+;
const int maxn=2e5+;
const double eps=1e-;
const double pi=acos(-1.0);
int n, m, c, l;
int de[maxn];
vector<int>nex[maxn];
queue<int>qu;
int flag[maxn];
 
int main()
{
int t;
while( ~ scanf("%d%d%d%d", &n, &m, &c, &l) )
{
for(int i=; i<=n; i++ )
{
nex[i].clear();
de[i]=;
flag[i]=;
}
 
while( !qu.empty() )
qu.pop();
for(int i=; i<=m; i++ )
{
int u, v;
scanf("%d%d", &u, &v);
nex[u].push_back(v);
nex[v].push_back(u);
de[u]++;
de[v]++;
}
 
flag[l]=;
qu.push(l);
while( !qu.empty() )
{
int cur=qu.front();
qu.pop();
for(int i=; i<nex[cur].size(); i++ )
{
de[nex[cur][i]]--;
if( de[nex[cur][i]]<=nex[nex[cur][i]].size()/ && flag[nex[cur][i]]== )
{
flag[nex[cur][i]] = ;//避免重复入栈
qu.push(nex[cur][i]);
}
}
}
if( flag[c]== )
cout<<"leave"<<endl;
else
cout<<"stay"<<endl;
}
return ;
}

Brexit Gym - 101490C的更多相关文章

  1. ACM: Gym 101047M Removing coins in Kem Kadrãn - 暴力

     Gym 101047M Removing coins in Kem Kadrãn Time Limit:2000MS     Memory Limit:65536KB     64bit IO Fo ...

  2. ACM: Gym 101047K Training with Phuket's larvae - 思维题

     Gym 101047K Training with Phuket's larvae Time Limit:2000MS     Memory Limit:65536KB     64bit IO F ...

  3. ACM: Gym 101047E Escape from Ayutthaya - BFS

    Gym 101047E Escape from Ayutthaya Time Limit:2000MS     Memory Limit:65536KB     64bit IO Format:%I6 ...

  4. ACM: Gym 101047B Renzo and the palindromic decoration - 手速题

     Gym 101047B  Renzo and the palindromic decoration Time Limit:2000MS     Memory Limit:65536KB     64 ...

  5. Gym 101102J---Divisible Numbers(反推技巧题)

    题目链接 http://codeforces.com/gym/101102/problem/J Description standard input/output You are given an a ...

  6. Gym 100917J---Judgement(01背包+bitset)

    题目链接 http://codeforces.com/gym/100917/problem/J Description standard input/outputStatements The jury ...

  7. Gym 100917J---dir -C(RMQ--ST)

    题目链接 http://codeforces.com/gym/100917/problem/D problem description Famous Berland coder and IT mana ...

  8. Gym 101102D---Rectangles(单调栈)

    题目链接 http://codeforces.com/gym/101102/problem/D problem  description Given an R×C grid with each cel ...

  9. Gym 101102C---Bored Judge(区间最大值)

    题目链接 http://codeforces.com/gym/101102/problem/C problem description Judge Bahosain was bored at ACM ...

随机推荐

  1. ADO.net(内置类区别)随记

    Ado.net使用流程 SqlConnection->open->SqlCommand(sqlstring,conn)->(ExcuteNonQuery \ExecuteScalar ...

  2. 七牛云图床存储+Alfread工作流+使用QSHELL

    layout: post title: 七牛云图床存储+Alfread工作流+使用QSHELL 来源:http://www.cnblogs.com/cmi-sh-love/p/8901620.html ...

  3. CSS疑难杂症

    1.text-align: center + letter-spacing: 2em 字体不居中 办法:添加text-indent: 2em 2.first-child伪类选择不到元素 办法:确保备选 ...

  4. 仿百度图片首页--HTML+CSS练手项目1【Table】

    [本文为原创,转载请注明出处] 技术[CSS+HTML]   布局[Table] 图片准备[百度图标.10张不同类型图] --------------------------------------- ...

  5. Java 缓存实例

    重复创建相同的对象没有太大的意义,反而加大了系统开销,某些情况下,可以缓存该类的实例,实现复用. 实现缓存实例:定义一个private static成员变量存储类的实例(多个可用数组)先检测上面的成员 ...

  6. IVS_技术

    视频监控技术按照设备发展过程分为三个阶段:模拟视频监控.数字视频监控.智能视频监控,如下图: 模拟视频监控 第一代视频监控系统也叫做闭路电视监控系统,简称CCTV(Close Circuit Tele ...

  7. GNS3、Wireshark、SecureCRT 环境部署

    本次GNS3环境部署教程基于官方推荐的稳定版1.5.4.初次接触此软件,详细的使用方法不是很清楚,所以以此作为学习记录,仅供参考,后期补充. 软件介绍 GNS3 GNS3是一款具有图形化界面可以运行在 ...

  8. fastJSON的常用方法总结

    fastJSON的常用方法总结 fastJSON中常用的对象是JSON,JSONArray,JSONObject三个对象.常用的方法如对象转为JSON字符串,JSON字符串转为对象,JSON字符串转为 ...

  9. mysql表的连接

    目录 1.笛卡尔积:将两表所有的数据一一对应,生成一张大表 2.连表查询 1.inner join 内连接 2.left join 左连接(left join左边的表为主表,主表记录必须全部显示,辅表 ...

  10. 【转】高性能网络编程6--reactor反应堆与定时器管理

    反应堆开发模型被绝大多数高性能服务器所选择,上一篇所介绍的IO多路复用是它的实现基础.定时触发功能通常是服务器必备组件,反应堆模型往往还不得不将定时器的管理囊括在内.本篇将介绍反应堆模型的特点和用法. ...