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 ...
随机推荐
- python --- 25 模块和包
一.模块 1.导入方式 自己创建的模块名称 切不可和 内置模块的一样 ① import 模块 ② import 模块 as 名 设置在此空间的名称 ③ from 模块 import ...
- oracle a:=100 和 b=:c 区别
a:=100 是赋值语句 b=:c :c是一个整体,表示一个参数.
- EControl的安装
EControl提供了运行期在窗体上进行界面设计的能力,手上的控件包是Delphi2010版的,在xe6下安装出现了一系列问题,弄了一晚上,总算搞定. 1.编译zDesign14.bpl包,修改DSN ...
- 获取当前的日期时间 格式“yyyy-MM-dd HH:MM:SS”
function getNowFormatDate() { var date = new Date(); var seperator1 = "-"; var ...
- eMMC应用教程:关于RPMB的应用【转】
本文转载自:https://blog.csdn.net/youdianhai/article/details/51246379 RPMB的意思是Replay Protected Memory Bloc ...
- 编译openwrt时报错:fstools-2018-01-02-11efbf3b/libfstools/overlay.c: At top level: cc1: error: unrecognized command line option '-Wno-format-truncation' [-Werror]
1. 详细错误信息 [ 11%] Building C object CMakeFiles/fstools.dir/libfstools/overlay.c.o/home/jello/openwrt/ ...
- How to Install LibreOffice 6.0 on Ubuntu 16.04 LTS +
1. Add the LibreOffice 6.0 PPA The LibreOffice Fresh PPA is maintained by LibreOffice. It provides l ...
- .NET BackgroundWorker的一般使用方式
代码如下: using System; using System.Collections.Generic; using System.ComponentModel; using System.Data ...
- (转)Jenkins持续集成
(二期)14.持续集成工具jenkins [课程14]持续集...概念.xmind0.6MB [课程14]持续集成...kins.xmind43.3KB [课程14预习]持续...kins.xmind ...
- js选择排序
选择排序 平均时间复杂度O(n*n) 最好情况O(n*n) 最差情况O(n*n) 空间复杂度O(1) 稳定性:不稳定 function chooseSort (arr) { var temp; var ...