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 ...
随机推荐
- NET Core 3.0 AutoFac替换内置DI的新姿势
原文:NET Core 3.0 AutoFac替换内置DI的新姿势 .NET Core 3.0 和 以往版本不同,替换AutoFac服务的方式有了一定的变化,在尝试着升级项目的时候出现了一些问题. 原 ...
- java之hibernate之组合主键映射
1.在应用中经常会有主键是由2个或多个字段组合而成的.比如成绩表: 第一种方式:把主键写为单独的类 2.类的设计:studentId,subjectId ,这两个主键是一个组件.所以可以采用组件映射的 ...
- Java 之 Cookie
Cookie 一.会话概述 1.会话:一次会话中包含多次请求和响应. 一次会话:浏览器第一次给服务器资源发送请求,会话建立,直到有一方断开为止. 2.功能: 在一次会话的范围内的多次请求间 ...
- 【知识点整理】Oracle中NOLOGGING、APPEND、ARCHIVE和PARALLEL下,REDO、UNDO和执行速度的比较
[知识点整理]Oracle中NOLOGGING.APPEND.ARCHIVE和PARALLEL下,REDO.UNDO和执行速度的比较 1 BLOG文档结构图 2 前言部分 2.1 导读和注意事项 ...
- MySQL Disk--MySQL磁盘问题排查
存储问题排查 1.检测磁盘空间使用率 df -lh 注意系统目录的可用空间 2.检查磁盘inode使用 df -i 参考:https://www.cnblogs.com/gaogao67/p/1088 ...
- docker启动报错解决及分析(Cannot create container for service *******: cannot mount volume over existing file, file exists /var/lib/docker/overlay2/)
现象: Cannot create container for service *******: cannot mount volume over existing file, file exists ...
- Locust性能模块浅谈
今天接触到Locust性能模块,下面介绍一下安装与简单的应用 1.安装方式:pip install Locust Locust支持Python 2.7, 3.4, 3.5, and 3.6的版本,小编 ...
- Linux操作系统之更改启动菜单的背景图实战案例
Linux操作系统之更改启动菜单的背景图实战案例 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. 一.制作图像并上传到服务器 1>.使用window 10操作系统自带的画图工具 ...
- Linux-网络RAID技术DRBD
DRBD简介 官方文档 DRBD的全称为:Distributed Replicated Block Device(DRBD)分布式块设备复制,DRBD是由内核模块和相关脚本构成,用以构建高可用的集群. ...
- 基于appium快速实现H5自动化测试
一.下载Appium-Server及库文件 库文件:jar包:java-client-3.1.0.jar Appium-Server:Appium服务器: 注:Appium包含客户端和服务端,客户端就 ...