Gym 101047M Removing coins in Kem Kadrãn
给定一个序列,只能拿走D,隔壁的会翻转,问能否全部拿走。
注意到如果能拿走的话,拿D的顺序是没关系的。模拟即可
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
using namespace std;
#define inf (0x3f3f3f3f)
typedef long long int LL; #include <iostream>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <string>
const int maxn = 1e5+;
char str[maxn];
char sub[maxn]; void work ()
{
char book[];
book['B']='D';
book['D']='B';
int n;
scanf("%d",&n);
scanf("%s",str+);
strcpy(sub+,str+); int did=;
int cnt=;
vector<int>ans;
int begin=;
int flag=;
for (int i=;i<=n;++i)
{
if (str[i]=='D')
{
flag=;
cnt++;
did += cnt;
cnt=;
str[i+]=book[str[i+]];
for (int j=i;j>=begin;--j)
{
ans.push_back(j);
}
begin=i+;
}
else cnt++;
} if (did==n)
{
printf ("Y\n");
for (int i=;i<ans.size();++i)
{
printf ("%d ",ans[i]);
}
printf ("\n");
}
else printf ("N\n");
return ;
} int main()
{
#ifdef local
freopen("data.txt","r",stdin);
#endif
int t;
scanf ("%d",&t);
while(t--) work();
return ;
}
Gym 101047M Removing coins in Kem Kadrãn的更多相关文章
- ACM:  Gym 101047M Removing coins in Kem Kadrãn - 暴力
		
Gym 101047M Removing coins in Kem Kadrãn Time Limit:2000MS Memory Limit:65536KB 64bit IO Fo ...
 - Gym 101606F - Flipping Coins - [概率DP]
		
题目链接:https://codeforc.es/gym/101606/problem/F 题解: 假设 $f[i][j]$ 表示抛 $i$ 次硬币,有 $j$ 个硬币正面朝上的概率. 所以只有两种挑 ...
 - Gym - 100712G Heavy Coins(二进制枚举)
		
https://vjudge.net/problem/Gym-100712G 题意:给出n枚不同价值的硬币和一个总价S,现在要选择尽量多的硬币来大于等于S,要求是比如说现在选择的硬币的总和为sum,那 ...
 - Gym 101606 F-Flipping Coins(概率dp)
		
参考博客:http://www.cnblogs.com/kang000/p/8571071.html (这篇博客写的真的走心,ORZ) 题意有n个硬币排成一排,开始的时候所有的硬币都是正面朝下,你必 ...
 - 18春季训练01-3/11 2015 ACM Amman Collegiate Programming Contest
		
Solved A Gym 100712A Who Is The Winner Solved B Gym 100712B Rock-Paper-Scissors Solved C Gym 100712C ...
 - AGC 033
		
目录 A. Darker and Darker B. LRUD Game 题面 题解 代码 C. Removing Coins 题面 题解 代码 D. Complexity 题面 题解 代码 E. G ...
 - AtCoder刷题记录
		
构造题都是神仙题 /kk ARC066C Addition and Subtraction Hard 首先要发现两个性质: 加号右边不会有括号:显然,有括号也可以被删去,答案不变. \(op_i\)和 ...
 - Codeforces & Atcoder神仙题做题记录
		
鉴于Codeforces和atcoder上有很多神题,即使发呆了一整节数学课也是肝不出来,所以就记录一下. AGC033B LRUD Game 只要横坐标或者纵坐标超出范围就可以,所以我们只用看其中一 ...
 - 【AtCoder】AGC033(A-F)
		
AGC033 A - Darker and Darker 直接BFS #include <bits/stdc++.h> #define fi first #define se second ...
 
随机推荐
- Send Code to evernote by my specify notebook
			
#coding:utf-8 import sys sys.path.append("lib") import thrift.protocol.TBinaryProtocol as ...
 - C#分词算法
			
本文用到的库下载:点此下载 词库下载:点此下载 将词库直接放到项目根目录 词库设置如下: 类库说明 词库查看程序:点此下载 可以在上面的程序中添加常用行业词库 还可以通过下面的类在程序中实现 完整的盘 ...
 - php命名空间(namespace)内如何使用系统类
			
作者:ffsystem 使用命名空间,可以更方便的组织代码,以及代码复用.新写的一个项目引入了命名空间. 简介:使用namespace,使用__autoload自动导入类. 今天将以前的一段代码,加入 ...
 - 修改sharepoint列表样式
			
1.将sharepoint 的样式修改为阴影 2.用designer打开列表的AllItems.aspx文件,将下面的样式拷贝到里面 <style type="text/css ...
 - 关于Windows文件读写_暗涌_新浪博客
			
关于Windows文件读写_暗涌_新浪博客 这几天在研究怎么才能加快windows文件读写速度,搜了很多文章,MSDN也看了不少.稍微给大家分享一下. 限制windows文件读写速度的 ...
 - Angular面试题
			
1. ng-show/ng-hide 与 ng-if的区别? 我们都知道ng-show/ng-hide实际上是通过display来进行隐藏和显示的.而ng-if实际上控制dom节点的增删除来实现的.因 ...
 - TCP/IP以及Socket对象基本
			
1 OSI七层模型概念介绍 物理层:数据以比特的方式进行传递,典型的设备是集线器.该层主要规定了设备的电压或者端口等等一些列物理层面上的规定 数据链路层:该层数据以帧的方式进行传递,主要是两个 ...
 - base64 数据加密
			
1.新建一个base64.js文件 添加下面的代码 /* Copyright (C) 1999 Masanao Izumo <iz@onicos.co.jp> * Version: 1.0 ...
 - assert.equal()
			
assert.equal(actual, expected[, message]) 使用相等运算符(==)测试 actual 参数与 expected 参数是否相等(通俗解释equal方法接受三个参数 ...
 - 32、Differential Gene Expression using RNA-Seq (Workflow)
			
转载: https://github.com/twbattaglia/RNAseq-workflow Introduction RNAseq is becoming the one of the mo ...