Brexit Gym - 101490C
题目链接: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的更多相关文章
- 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 ...
- ACM: Gym 101047K Training with Phuket's larvae - 思维题
Gym 101047K Training with Phuket's larvae Time Limit:2000MS Memory Limit:65536KB 64bit IO F ...
- ACM: Gym 101047E Escape from Ayutthaya - BFS
Gym 101047E Escape from Ayutthaya Time Limit:2000MS Memory Limit:65536KB 64bit IO Format:%I6 ...
- ACM: Gym 101047B Renzo and the palindromic decoration - 手速题
Gym 101047B Renzo and the palindromic decoration Time Limit:2000MS Memory Limit:65536KB 64 ...
- Gym 101102J---Divisible Numbers(反推技巧题)
题目链接 http://codeforces.com/gym/101102/problem/J Description standard input/output You are given an a ...
- Gym 100917J---Judgement(01背包+bitset)
题目链接 http://codeforces.com/gym/100917/problem/J Description standard input/outputStatements The jury ...
- Gym 100917J---dir -C(RMQ--ST)
题目链接 http://codeforces.com/gym/100917/problem/D problem description Famous Berland coder and IT mana ...
- Gym 101102D---Rectangles(单调栈)
题目链接 http://codeforces.com/gym/101102/problem/D problem description Given an R×C grid with each cel ...
- Gym 101102C---Bored Judge(区间最大值)
题目链接 http://codeforces.com/gym/101102/problem/C problem description Judge Bahosain was bored at ACM ...
随机推荐
- WPF 使用 AppBar 将窗口停靠在桌面上,让其他程序不占用此窗口的空间(附我封装的附加属性)
原文:WPF 使用 AppBar 将窗口停靠在桌面上,让其他程序不占用此窗口的空间(附我封装的附加属性) 本文介绍如何使用 Windows 的 AppBar 相关 API 实现固定停靠在桌面上的特殊窗 ...
- kali之nmap
nmap简介 Nmap,也就是Network Mapper,最早是Linux下的网络扫描和嗅探工具包.可以扫描主机.端口.并且识别端口所对应的协议,以及猜测操作系统 Ping扫描(-sP参数) TCP ...
- iOS 12中获取WiFi的SSID
开始搞智能家居,wifi获取不到了?? 小插曲 旧方法失效,19-12-15更新,ios13开始需要请求定位信息 SSID全称Service Set IDentifier, 即Wifi网络的公开名称. ...
- JUC - ThreadPoolExecutor
JUC - ThreadPoolExecutor 创建一个ThreadPoolExecutor ThreadPoolExecutor( int corePoolSize, // 保留在池中的线程数,即 ...
- IntelliJ idea鼠标移动到类上显示文档document(javadoc)内容
IntelliJ idea鼠标移动到类上显示文档document(javadoc)内容 Step 1:设置鼠标移动到类上自动显示Javadoc文档 step2:为jdk下载javadoc Step3: ...
- Vue学习之webpack调用第三方loader(十五)
---恢复内容开始--- 一.webpack 默认只能打包处理 JS 类型的文件,无法处理 其他的非 JS 类型的文件: 如果非要处理 非 JS 类型的文件,我们需要手动安装一些 合适 第三方 lo ...
- dede自定义内容模型下,列表只显示10条的问题及解决方法
<div class="zjtd-content-ld s-content"> {dede:arclist tagid='ld' row='100' pagesize= ...
- 【Win10】系统修改
1.删除“快速访问”[操作说明] a.打开HKEY_CLASSES_ROOT\CLSID\{679f85cb-0220-4080-b29b-5540cc05aab6}\ShellFolder ...
- Git版本管理工具使用
1.Git简介 Git(读音为/gɪt/.)是一个开源的分布式版本控制系统,可以有效.高速地处理从很小到非常大的项目版本管理. Git 是 Linus Torvalds 为了帮助管理 Linux 内核 ...
- 在Linux系统上安装Spring boot应用
Unix/Linux 服务 systemd 服务 操作过程 1. 安装了JDK的centOS7虚拟机 注意下载linux版本JDK的时候不能直接通过wget这种直接链接下载,否则会解压不成功,应该打开 ...