sgu 191 Exhibition
题意:开始只有某一展台(设为A),有2种操作。1.A展台上放B产品(或者B展台放A产品)。2.A展台左边1位放B展台,左边2位放A产品。给出最终产品的排列,问能否实现。
考虑最后一个用2操作的展台,因为是最后一个用2操作的展台,它的左边2个一定是对方的。比如A展台最后要放B产品,而它左边2位都放A产品。就用栈将AAB这样的转换成B再压回栈中。
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cstring>
#include <map>
#include <queue>
#include <set>
#include <cassert>
#include <stack>
#define mkp make_pair
using namespace std;
const double EPS=1e-;
typedef long long lon;
const int SZ=,INF=0x7FFFFFFF; void init()
{ } void work()
{ } int main()
{
std::ios::sync_with_stdio();
//freopen("d:\\1.txt","r",stdin);
lon casenum;
//cin>>casenum;
//for(lon time=1;time<=casenum;++time)
{
char src;
string str;
cin>>src>>str;
vector<char> stk;
for(int i=;i<str.size();++i)
{
stk.push_back(str[i]);
for(;stk.size()>=;)
{
bool bl1=stk[stk.size()-]!=stk[stk.size()-];
bool bl2=stk[stk.size()-]!=stk[stk.size()-];
if(bl1&&bl2)
{
stk.pop_back(),stk.pop_back(),stk.pop_back();
stk.push_back(str[i]);
}
else break;
}
}
if(stk.size()==&&stk[]!=src)cout<<"YES"<<endl;
else cout<<"NO"<<endl;
}
return ;
}
sgu 191 Exhibition的更多相关文章
- SGU 191.Exhibition(模拟)
时间限制:0.25s 空间限制:4M 题意: 有两个公司A.B,他们要展览物品,但是A公司的展柜要放B公司的物品,B公司的展柜要放A公司物品.最开始只有一个空柜台,从指定的一个公司开始,轮流进行操作, ...
- SGU 分类
http://acm.sgu.ru/problemset.php?contest=0&volume=1 101 Domino 欧拉路 102 Coprime 枚举/数学方法 103 Traff ...
- SGU Volume 1
SGU 解题报告(持续更新中...Ctrl+A可看题目类型): SGU101.Domino(多米诺骨牌)------------★★★type:图 SGU102.Coprimes(互质的数) SGU1 ...
- 【OpenJudge 191】【POJ 1189】钉子和小球
http://noi.openjudge.cn/ch0405/191/ http://poj.org/problem?id=1189 一开始忘了\(2^{50}\)没超long long差点写高精度Q ...
- leetcode 191
191. Number of 1 Bits Write a function that takes an unsigned integer and returns the number of ’1' ...
- (01背包变形) Cow Exhibition (poj 2184)
http://poj.org/problem?id=2184 Description "Fat and docile, big and dumb, they look so stupid ...
- POJ2184 Cow Exhibition[DP 状态负值]
Cow Exhibition Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 12420 Accepted: 4964 D ...
- SGU 495. Kids and Prizes
水概率....SGU里难得的水题.... 495. Kids and Prizes Time limit per test: 0.5 second(s)Memory limit: 262144 kil ...
- ACM: SGU 101 Domino- 欧拉回路-并查集
sgu 101 - Domino Time Limit:250MS Memory Limit:4096KB 64bit IO Format:%I64d & %I64u Desc ...
随机推荐
- Python3 tkinter基础 Entry state 不可写 可以选 可复制的输入框
Python : 3.7.0 OS : Ubuntu 18.04.1 LTS IDE : PyCharm 2018.2.4 Conda ...
- Python3 tkinter基础 Entry insert delete 点击按钮 向输入框赋值 或 清空
Python : 3.7.0 OS : Ubuntu 18.04.1 LTS IDE : PyCharm 2018.2.4 Conda ...
- Django 中如何让外部访问本地的静态资源
简单使用 在Django中打开一个入口,让别人可以访问media文件 在settings中配置 MEDIA_ROOT=os.path.join(BASE_DIR,'media') 在路由中配置 fro ...
- tp框架中的一些疑点知识-2
tp中有三种常量: 预定义常量, 这个设置后不会随环境的改变而改变的,比如'URL_MODEL' => 1 注意是 model, 不是 url_mode 路径常量, 也不会随环境的改变而改变的, ...
- Attribute2Image --- Conditional Image Generation from Visual Attributes 论文笔记
Attribute2Image --- Conditional Image Generation from Visual Attributes Target: 本文提出一种根据属性生成图像的产生式模 ...
- 原生js仿jquery一些常用方法
原生js仿jquery一些常用方法 下面小编就为大家带来一篇原生js仿jquery一些常用方法(必看篇).小编觉得挺不错的,现在就分享给大家,也给大家做个参考.一起跟随小编过来看看吧 最近迷上了原 ...
- ASP.NET MVC AntiForgeryToken
你开发一个网站,其中有个功能:新闻发布. 你是这样实现的: 1.保存新闻的方法是:/News/Save POST提交 2.接受两个参数:title和content 有一天,你登录网站(浏览器会保存相 ...
- React-navigation物理返回键提示效果BackHandler
componentWillMount(){ BackHandler.addEventListener('hardwareBackPress', this.onBackAndroid); } co ...
- React Native 组建之IOS和Android通用抽屉
/** * Sample React Native App * https://github.com/facebook/react-native * @flow *npm:https://www.np ...
- 在ETH交易区块链里查看北大的那封信
本文仅限于科普编码知识使用,随便举的例子不代表本人立场. 欢迎在其他网站传播,但转载不得标注来源及作者. 1.随便打开一个ETH区块链浏览网站,比如:https://www.etherchain.or ...