题目链接: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. 2、Shell命令学习笔记

    1.Shell命令行解释器 1.1 Shell命令解释器 Shell是一个特殊的应用程序,介于操作系统内核和用户之间,负责接收用户输入的操作指令(命令)并进行解释,将需要执行的操作传递给内核执行. 因 ...

  2. springcolud 的学习(四)服务治理. Eureka

    什么是服务治理在传统rpc远程调用中,服务与服务依赖关系,管理比较复杂,所以需要使用服务治理,管理服务与服务之间依赖关系,可以实现服务调用.负载均衡.容错等,实现服务发现与注册.服务注册与发现 在服务 ...

  3. React 语法

    1.JavaScript XML JSX = JavaScript XML,是一个看起来很像 XML 的 JavaScript 语法扩展.JSX 不是模板,是JS语法本身,有更多的扩展.JSX 组件一 ...

  4. WinForm下开发插件DevExpress安装及使用

    WinForm下开发插件DevExpress安装及使用在Visual Studio中安装DevExpress开发插件插件的使用方法简单的Demo介绍下载链接:https://pan.baidu.com ...

  5. tf.tile()函数的用法

    y = tf.tile(tf.range(2, dtype=tf.int32)[:, tf.newaxis], [2,3]) # tf.tile(input,[a,b]) 输入数据,按照对应维度将矩阵 ...

  6. 2019 前程无忧java面试笔试题 (含面试题解析)

    本人3年开发经验.18年年底开始跑路找工作,在互联网寒冬下成功拿到阿里巴巴.今日头条.前程无忧等公司offer,岗位是Java后端开发,最终选择去了前程无忧. 面试了很多家公司,感觉大部分公司考察的点 ...

  7. Flask 和 Django 框架的区别

    1)Flask Flask确实很“轻”,不愧是Micro Framework,从Django转向Flask的开发者一定会如此感慨,除非二者均为深入使用过 Flask自由.灵活,可扩展性强,第三方库的选 ...

  8. Tensorflow替换静态图中的OP

    import tensorflow as tf import collections from tensorflow.core.framework import tensor_shape_pb2 # ...

  9. ningx配置本地https环境

    由于项目改成了https访问,所以本地开发的时候也要通过https验证,避免页面发送http请求. 例如原来是这样访问:http://192.168.88.88:8080/ 或 http://loca ...

  10. suctf2019 部分web题目的复盘

    1.简单的SQL注入 一开始一直没思路,输入什么过滤什么,结束后看了大佬们的wp,感觉学到了,这里涉及到Mysql中的一个特殊模式的设置 set sql_mode=pipes_as_concat; 这 ...