题目链接: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. 1.将控制器添加到 ASP.NET Core MVC 应用

    模型-视图-控制器 (MVC) 体系结构模式将应用分成 3 个主要组件:模型 (M).视图 (V) 和控制器 (C). 模型(M):表示应用数据的类. 模型类使用验证逻辑来对该数据强制实施业务规则. ...

  2. c#利用定时器自动备份数据库(mysql)

    1:引用dll MySql.Data.dll,   MySqlbackup.dll 2:建一个数据连接静态类 public static class mysql{public static strin ...

  3. java之mybatis之动态sql

    1. if 判读条件是否满足,满足将会把 sql 语句加上. <select id="findUser" parameterType="Map" resu ...

  4. Resharper2019 1.2破解教程

    下载安装 Resharper 去Resharper官网下载安装 Resharper官网地址 Resharper下载地址 破解 (破解dll百度网盘链接)[https://pan.baidu.com/s ...

  5. 2019 东软java面试笔试题 (含面试题解析)

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

  6. IDEA中调试时F8,F7快捷键失效

    idea中调试时F8,F7快捷键失效 原因:相关软件的快捷键占用了F8,F7,如我的有道词典占用F8了这个快捷键,导致idea调试时不能使用F8,改变有道词典的快捷键即可.

  7. JavaScript笔记02_对象

    目录 1. 函数 1. 函数创建 2. 函数的参数 2. return.break.continue 3. 立即执行函数 4. 对象 5. 枚举对象中的属性 6. 声明提前 1.变量的声明提前 2. ...

  8. Android笔记(七十四) 详解Intent

    我们最常使用Intent来实现Activity之间的转跳,最近做一个app用到从系统搜索图片的功能,使用到了intent的 setType 方法和 setAction 方法,网上搜索一番,发现实现转跳 ...

  9. 解决iOS微信H5支付跳转微信后不返回App问题(Swift-WKWebview)(转)

    问题分析 正常的H5支付流程如下 按照上面的支付流程会出现 App -> 微信 -> 支付 -> 点击 完成 -> safari访问redirect_url设置的URL,这种流 ...

  10. nodejs 将不同文件夹中的视频整合到一个文件夹中

    var fs = require("fs") var path = require("path") var listRealPath = path.resolv ...