cf D. Alternating Current
http://codeforces.com/contest/344/problem/D
#include <cstdio>
#include <cstring>
#include <stack>
#include <algorithm>
using namespace std; char str[];
int main()
{
stack<char>q;
scanf("%s",str);
int k=strlen(str);
for(int i=; i<k; i++)
{
if(q.empty())
{
q.push(str[i]);
}
else if(str[i]==q.top())
{
q.pop();
}
else if(str[i]!=q.top())
{
q.push(str[i]);
}
}
if(!q.empty()) printf("No\n");
else printf("Yes\n");
return ;
}
cf D. Alternating Current的更多相关文章
- Codeforces Round #200 (Div. 1) B. Alternating Current 栈
B. Alternating Current Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/343 ...
- CodeForces - 344D Alternating Current (模拟题)
id=46667" style="color:blue; text-decoration:none">CodeForces - 344D id=46667" ...
- Codeforces Round #200 (Div. 2)D. Alternating Current (堆栈)
D. Alternating Current time limit per test 1 second memory limit per test 256 megabytes input standa ...
- Alternating Current
Codeforces Round #200 (Div. 1) B:http://codeforces.com/problemset/problem/343/B 题意:这一题看懂题意是关键,题目的意思就 ...
- CF 964C Alternating Sum
给定两正整数 $a, b$ .给定序列 $s_0, s_1, \dots, s_n,s_i$ 等于 $1$ 或 $-1$,并且已知 $s$ 是周期为 $k$ 的序列并且 $k\mid (n+1)$,输 ...
- Codeforces 344D Alternating Current 简单使用栈
Description Mad scientist Mike has just finished constructing a new device to search for extraterres ...
- [CodeForces 344D Alternating Current]栈
题意:两根导线绕在一起,问能不能拉成两条平行线,只能向两端拉不能绕 思路:从左至右,对+-号分别进行配对,遇到连续的两个“+”或连续的两个“-”即可消掉,最后如果全部能消掉则能拉成平行线.拿两根线绕一 ...
- 跟着xiaoxin巨巨做cf
cf 385 C. Bear and Prime Numbers 题目大意:有一个数列{xi},每次给出一个询问[l, r],即问 S(l ,r)是l和r之间的素数,f(p)表示数列{xi}中整除p的 ...
- HBase 数据模型(Data Model)
HBase Data Model--HBase 数据模型(翻译) 在HBase中,数据是存储在有行有列的表格中.这是与关系型数据库重复的术语,并不是有用的类比.相反,HBase可以被认为是一个多维度的 ...
随机推荐
- CCI_chapter 1
1.1Implement an algorithm to determine if a string has all unique characters What if you can not us ...
- C8051F学习笔记:单片机的驱动能力
学习51单片机的时候我们就知道51单片机的I/O口的特点:P0口没有弱上拉,所以做地址线时不用上拉,但输出“1”时就要加上拉电阻,不然输出电平到不了高电平,P1~P3则不存在这个问题,每个输出管脚都有 ...
- 免费邮件服务器:MailEnable
官方网站地址:www.mailenable.com 下载最新版的 Standard Edition (FREE) 安装之前请留意安装指引就可以了,安装上去之后,直接就可以使用了 安装指引上写的清清楚楚 ...
- ViewPager顶部标题控件PagerSlidingTabStrip
最近搞一个项目,要求做一个和网易新闻顶部菜单的滑动效果,如图: 顶部标题中下面有个红色的矩形小条,左右滑动时会跟随手势动态滑动,效果很绚丽,唉,特效啊! 自己搞了一上午无果,还是是github上找大神 ...
- DEV GridControl 鼠标单击事件
private void gridView1_RowClick(object sender, DevExpress.XtraGrid.Views.Grid.RowClickEventArgs e) { ...
- 如何让网页打开就运行JS代码,不用onclick
打开网页直接运行是要调用window.onload( )函数: <html> <head> </head> <body> < ...
- WebApi2官网学习记录---Tracing
安装追踪用的包 Install-Package Microsoft.AspNet.WebApi.Tracing Update-Package Microsoft.AspNet.WebApi.WebHo ...
- C#读取XML配置文件
DataSource.xml文件,要放在bin/debug/目录下: <?xml version="1.0" encoding="utf-8" ?> ...
- 对arm指令集的疑惑,静态库运行,编译报错等问题
转载自http://www.jianshu.com/p/4a70aa03a4ea?utm_campaign=hugo&utm_medium=reader_share&utm_conte ...
- return 与 finally
(function hello() { try { return console.log('return'); } catch (e) { } finally { console.log('final ...