coderforce A. Case of the Zeros and Ones
来源:互联网 发布:mac中如何复制粘贴 编辑:程序博客网 时间:2024/06/05 00:13
题意:相邻的0和1或者1和0可以消除,问最后字符串还有多少个字符
#include<stdio.h>#include<string.h>#include<string>#include<stack>#include<algorithm>using namespace std;const int maxm=1e5+10;char s[maxm<<1];int main(){ int n; while(scanf("%d",&n)!=EOF) { scanf("%s",s); stack<char>q; int temp=n; for(int i=0; i<n; i++) { if(!q.empty()) { char a=q.top(); if(s[i]!=a) { temp-=2; q.pop(); } else { q.push(s[i]); } } else { q.push(s[i]); } } printf("%d\n",temp); } return 0;}
0 0
- coderforce A. Case of the Zeros and Ones
- A. Case of the Zeros and Ones
- A. Case of the Zeros and Ones
- CodeForces 556A Case of the Zeros and Ones
- CodeForces-556A Case of the Zeros and Ones
- codeforces 556A Case of the Zeros and Ones
- Codeforces 556A:Case of the Zeros and Ones
- CodeForces 556A Case of the Zeros and Ones
- 【52.49%】【codeforces 556A】Case of the Zeros and Ones
- Case of the Zeros and Ones
- Case of the Zeros and Ones
- Case of the Zeros and Ones
- Codeforces 556A Case of the Zeros and Ones 消除01串
- A. Case of the Zeros and Ones(Codeforces Round #310 (Div. 2) 栈)
- CF#310-A-Case of the Zeros and Ones-链表模拟
- CodeForces NO.556A Case of the Zeros and Ones(stack,110101010)
- Codeforces Round #310 (Div. 2)-A. Case of the Zeros and Ones
- the Zeros and Ones
- C++调用python
- HDU 2864 Repository 字典树
- xutils dbutils使用中遇到的问题
- 读《中国文学史》
- 02-使用C3P0连接池连接MySql并且使用QueryRunner简化数据库操作
- coderforce A. Case of the Zeros and Ones
- LeetCode(155) Min Stack
- cocos2dx 苹果5分辨率 适配错误
- 程序读取特定目录下的字符数
- unity3d 获取系统硬件信息
- oracle监听开启trace file
- [计算机导论思维与系统(一)]
- Android仿微信通通讯录
- 51nod 1393 0和1相等串 (连续区间)