Codeforces Round #200 (Div. 1) B:http://codeforces.com/problemset/problem/343/B

题意:这一题看懂题意是关键,题目的意思就是两根a,b电线相互缠绕,+表示a在b的上面,-表示b在a的上面,给以一个串,然后问你这两根线能否解开。

题解:显然,如果两个相邻的++或者--的话可以直接消去,然后就会想到用栈来模拟,相同的就消去,不同的就进栈,最后判断栈内是否为空就可以了。

 #include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int N=1e5+;
char ans[N],a[N];
int n,top;
int main(){
while(~scanf("%s",a)){
n=strlen(a);top=;
for(int i=;i<n;i++){
if(top==){
ans[++top]=a[i];
}
else if(a[i]==ans[top]){
top--;
}
else ans[++top]=a[i];
}
if(top==)printf("Yes\n");
else
printf("No\n");
}
}

Alternating Current的更多相关文章

  1. Codeforces Round #200 (Div. 1) B. Alternating Current 栈

    B. Alternating Current Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/343 ...

  2. CodeForces - 344D Alternating Current (模拟题)

    id=46667" style="color:blue; text-decoration:none">CodeForces - 344D id=46667" ...

  3. 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 ...

  4. cf D. Alternating Current

    http://codeforces.com/contest/344/problem/D #include <cstdio> #include <cstring> #includ ...

  5. Codeforces 344D Alternating Current 简单使用栈

    Description Mad scientist Mike has just finished constructing a new device to search for extraterres ...

  6. [CodeForces 344D Alternating Current]栈

    题意:两根导线绕在一起,问能不能拉成两条平行线,只能向两端拉不能绕 思路:从左至右,对+-号分别进行配对,遇到连续的两个“+”或连续的两个“-”即可消掉,最后如果全部能消掉则能拉成平行线.拿两根线绕一 ...

  7. Electronic oscillator

    https://en.wikipedia.org/wiki/Electronic_oscillator An electronic oscillator is an electronic circui ...

  8. Arduino 极速入门系列 - 光控灯(1)- 关于理论和 LED 那些事

    点个 LED 闪亮好像太单调,这次来个光控 LED 灯.这个其实不需要 Arduino 也能做,这次只是用来演示一下 PWM 在 Arduino 里面的做法.PWM 原理后面会解释.这次用充电宝提供 ...

  9. RFID 基础/分类/编码/调制/传输

    不同频段的RFID产品会有不同的特性,本文详细介绍了无源的感应器在不同工作频率产品的特性以及主要的应用. 目前定义RFID产品的工作频率有低频.高频和甚高频的频率范围内的符合不同标准的不同的产品,而且 ...

随机推荐

  1. End-to-End Tracing of Ajax/Java Applications Using DTrace

    End-to-End Tracing of Ajax/Java Applications Using DTrace         By Amit Hurvitz, July 2007     Aja ...

  2. cookie记录用户名和密码

    getAttribute和getParameter的区别: request.getAttribute():是request时设置的变量的值,用request.setAttribute("na ...

  3. Java基础知识强化之集合框架笔记50:Map集合之Map集合的概述和特点

    1. Map集合的概述: public interface Map<K,V> 作为学生来说,是根据学号来区分不同的学生的,那么假设我现在已经知道了学生的学号,我要根据学号去获取学生姓名,请 ...

  4. Chapter 3. Installing Gradle 安装gradle

    3.1. Prerequisites Gradle requires a Java JDK or JRE to be installed, version 6 or higher (to check, ...

  5. Install-User.ps1

    Install-User.ps1 function Install-User { param( [Parameter()] [string]$ComputerName = $env:computern ...

  6. 插件使用总结-jquery.pin.js

    小伙伴们,俺昨天用了jquery.pin.js这个插件,发现了一些自以为是的使用问题.特此做个总结哈. 1.获取: 下载地址:  http://www.bootcss.com/p/jquery.pin ...

  7. JVM垃圾回收理论知识

  8. 滚动效果,marquee便签

    语法: <marquee></marquee> 例子: <marquee><font size=+3 color=red>Hello, World< ...

  9. c语言学习之基础知识点介绍(三):scanf函数

    本节继续介绍c语言的基础知识点. scanf函数:用来接收用户输入的数据. 语法:scanf("格式化控制符",地址列表); 取地址要用到取地址符:&(shift+7) 例 ...

  10. .NET(C#):获取进程的内存私有工作集

    当前.NET Framework(.NET 4.0)的Process仅提供进程的内存工作集的获取(通过WorkingSet64属性),而没有提供对私有工作集的获取.注意在Windows Vista之后 ...