题意:开始只有某一展台(设为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的更多相关文章

  1. SGU 191.Exhibition(模拟)

    时间限制:0.25s 空间限制:4M 题意: 有两个公司A.B,他们要展览物品,但是A公司的展柜要放B公司的物品,B公司的展柜要放A公司物品.最开始只有一个空柜台,从指定的一个公司开始,轮流进行操作, ...

  2. SGU 分类

    http://acm.sgu.ru/problemset.php?contest=0&volume=1 101 Domino 欧拉路 102 Coprime 枚举/数学方法 103 Traff ...

  3. SGU Volume 1

    SGU 解题报告(持续更新中...Ctrl+A可看题目类型): SGU101.Domino(多米诺骨牌)------------★★★type:图 SGU102.Coprimes(互质的数) SGU1 ...

  4. 【OpenJudge 191】【POJ 1189】钉子和小球

    http://noi.openjudge.cn/ch0405/191/ http://poj.org/problem?id=1189 一开始忘了\(2^{50}\)没超long long差点写高精度Q ...

  5. leetcode 191

    191. Number of 1 Bits Write a function that takes an unsigned integer and returns the number of ’1' ...

  6. (01背包变形) Cow Exhibition (poj 2184)

    http://poj.org/problem?id=2184   Description "Fat and docile, big and dumb, they look so stupid ...

  7. POJ2184 Cow Exhibition[DP 状态负值]

    Cow Exhibition Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 12420   Accepted: 4964 D ...

  8. SGU 495. Kids and Prizes

    水概率....SGU里难得的水题.... 495. Kids and Prizes Time limit per test: 0.5 second(s)Memory limit: 262144 kil ...

  9. ACM: SGU 101 Domino- 欧拉回路-并查集

    sgu 101 - Domino Time Limit:250MS     Memory Limit:4096KB     64bit IO Format:%I64d & %I64u Desc ...

随机推荐

  1. topcoder srm 704 div1

    1.对于一棵树上的一个节点$u$,定义$f(u)$表示树上距离$u$最远的节点到$u$的距离.给出每个节点的$f$值,构造出这棵树. 思路:找到树的主干,然后不在主干上的节点一定可以连接到主干的某个节 ...

  2. Spring-Cache 注解 @Cacheable,@CachePut , @CacheEvict

    1.自动生成key @Bean public KeyGenerator keyGenerator() { return new KeyGenerator() { @Override public Ob ...

  3. CodeForces 459C Pashmak and Buses(构造)题解

    题意:n个人,k辆车,要求d天内任意两人都不能一直在同一辆车,能做到给出构造,不能输出-1 思路:我们把某一个人这d天的车号看成一个d位的数字,比如 1 1 2 3代表第一天1号车.第二天1号车.第三 ...

  4. 【Finchley】【升级变更】Spring Cloud 升级到Finchley版本后需要注意的地方

    Spring Boot 2.x 已经发布了很久,现在 Spring Cloud 也发布了 基于 Spring Boot 2.x 的 Finchley 版本,现在一起为项目做一次整体框架升级. 升级前 ...

  5. Android开发——去掉系统自带标题栏的几种方式

    https://blog.csdn.net/qq_28585471/article/details/75991613 今天在练习自定义标题栏(Android初级开发(四)——补充3)的过程中遇到了隐藏 ...

  6. Yarn 的日志聚集功能配置使用

    需要  hadoop 的安装目录/etc/hadoop/yarn-site.xml 中进行配置 配置内容 <property> <name>yarn.log-aggregati ...

  7. skype for business 无法共享桌面、无法传输图片

    以管理员身份运行如下PowerShell命令,清除Skype for Business缓存记录 #以管理员身份运行如下PowerShell命令,清除Skype for Business缓存记录 Sto ...

  8. ESP8266 使用

    ESP8266 微机使用串口和ESP8266建立通信,ESP8266把消息通过wifi发送出去 助手软件 网络调试助手 串口调试助手 AT指令 指令 作用 AT 测试是否进入AT模式 AT+RST 重 ...

  9. SE91 SAP消息类型

    SE91 SAP消息类型 E:Error W:Warning I  :Information A :Abortion S :Success 标准 : MESSAGE ID sy-msgid TYPE  ...

  10. File操作-将数据库里的数据写入到指定路径的txt文件里

    package com.Cristin.File;//将数据库里的数据写入到指定路径的txt文件里 import java.io.File;import java.io.FileOutputStrea ...