HDU 4665 Unshuffle (2013多校6 1011 )
Unshuffle
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 148 Accepted Submission(s): 43
Special Judge
shuffle of two strings is formed by interspersing the characters into a
new string, keeping the characters of each string in order. For
example, MISSISSIPPI is a shuffle of MISIPP and SSISI. Let me call a
string square if it is a shuffle of two identical strings. For example,
ABCABDCD is square, because it is a shuffle of ABCD and ABCD, but the
string ABCDDCBA is not square.
Given a square string, in which each character occurs no more than four times, unshuffle it into two identical strings.
Following
are 2*T lines. For every two lines, the first line is n, length of the
square string; the second line is the string. Each character is a
positive integer no larger than n.
T<=10, n<=2000.
lines. Each line is a string of length n of the corresponding test
case. '0' means this character belongs to the first string, while '1'
means this character belongs to the second string. If there are multiple
answers, output any one of them.
8
1 2 3 1 2 4 3 4
/*
* Author: kuangbin
* File Name: 1011.cpp
*/
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <algorithm>
using namespace std; const int MAXN = ;
int a[MAXN];
int s[MAXN];
char ans[MAXN]; bool flag ;
int n;
void dfs(int cur,int t1,int t2)
{
if(flag)return;
if(t1 > n/ || t2 > n/)return;
if(cur == n)
{
flag = true;
return;
}
s[t1] = a[cur];
ans[cur] = '';
dfs(cur+,t1+,t2);
if(flag)return;
if(s[t2] == a[cur])
{
ans[cur] = '';
dfs(cur+,t1,t2+);
}
} int main()
{
int T;
scanf("%d",&T);
while(T--)
{
scanf("%d",&n);
for(int i = ;i < n;i++)
scanf("%d",&a[i]);
flag = false;
dfs(,,);
for(int i = ;i < n;i++)printf("%c",ans[i]);
printf("\n");
}
return ;
}
HDU 4665 Unshuffle (2013多校6 1011 )的更多相关文章
- HDU 4642 Fliping game (2013多校4 1011 简单博弈)
Fliping game Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Tota ...
- HDU 4631 Sad Love Story (2013多校3 1011题 平面最近点对+爆搞)
Sad Love Story Time Limit: 40000/20000 MS (Java/Others) Memory Limit: 131072/65536 K (Java/Others ...
- HDU 4970(杭电多校#9 1011题)Killing Monsters(瞎搞)
题目地址:HDU 4970 先进行预处理.在每一个炮塔的火力范围边界标记一个点. 然后对每一个点的伤害值扫一遍就能算出来. 然后在算出每一个点到终点的总伤害值,并保存下来,也是扫一遍就可以. 最后在询 ...
- HDU/杭电2013多校第三场解题报告
今天悲剧了,各种被虐啊,还是太年轻了 Crime 这道题目给的时间好长,第一次就想到了暴力,结果华丽丽的TLE了. 后来找了一下,发现前24个是1, 2, 6, 12, 72, 72, 864, 17 ...
- HDU 4665 Unshuffle DFS找一个可行解
每层找一对相等的整数,分别放在两个不同的串中. 参考了学弟的解法,果断觉得自己老了…… #include <cstdio> #include <cstring> #includ ...
- HDU 4758 Walk Through Squares (2013南京网络赛1011题,AC自动机+DP)
Walk Through Squares Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 65535/65535 K (Java/Oth ...
- HDU 4705 Y (2013多校10,1010题,简单树形DP)
Y Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others)Total Submiss ...
- HDU 4704 Sum (2013多校10,1009题)
Sum Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others)Total Submi ...
- HDU 4699 Editor (2013多校10,1004题)
Editor Time Limit: 3000/2000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others)Total Su ...
随机推荐
- [hadoop][基本原理]zookeeper基本原理
1.简介 https://www.ibm.com/developerworks/cn/opensource/os-cn-zookeeper/ 2. 数据模型 Zookeeper 会维护一个具有层次关系 ...
- CSS中cursor属性给标签加上小手形状
HTML/CSS 2012-08-10 CSS,标签 我们发现a标签在网页中有一个值得注意的地方,即鼠标移到a标签上光标会变成一只小手的图标,移出a标签后又恢复为默认箭头. 如今,JS在网页中的功能越 ...
- Mac 使用自带的Ruby 安装brew
Homebrew简称brew,OSX上的软件包管理工具,在Mac终端可以通过brew安装.更新.卸载软件. 首先要安装brew,在 mac 中使用finder 搜索 终端(terminal)打开命令行 ...
- 22:django 配置详解
django配置文件包含了你的django安装的所有配置信息,本节为大家详细讲解django的配置 基本知识 一个配置文件只是一个包含模块级别变量的的python模块,所有的配置变量都是大写的,哈哈哈 ...
- python_day5学习笔记
一.正则表达式 字符: \d 匹配任何十进制数:相当于类[0-9] \D 匹配任何非数字字符:相当于类[^0-9] \s 匹配任何空白字符:相当于类[ \t\n\r\f\v] \S 匹配任何非空 ...
- setTimeout(fn,0)
我们都知道setTimeout是一个延迟执行的函数 console.log(); setTimeout(function(){console.log();},); console.log(); 会得到 ...
- GITHUB个人博客搭建-Pelican 在Windows环境下的安装及配置
GITHUB个人博客搭建-Pelican 在Windows环境下的安装及配置 前言 此篇博客主要为Pelican在Windows平台下的配置安装所写,在此过程中主要参考资料烟雨林博客.poem_of_ ...
- webStorm配置es6转es5
话说又开始新项目了,刚好今天学习的es6新语法可以试试手,回到家后开始继续学习,然后只是学习es6没有必要弄个gulp,总觉得浪费. 那么前端开发神器的webStorm是一定会支持es6的,于是百度了 ...
- 微软企业库5.0 学习之路——第八步、使用Configuration Setting模块等多种方式分类管理企业库配置信息
在介绍完企业库几个常用模块后,我今天要对企业库的配置文件进行处理,缘由是我打开web.config想进行一些配置的时候发现web.config已经变的异常的臃肿(大量的企业库配置信息充斥其中),所以决 ...
- CentOS7安装私有gitlab
1.安装依赖包 yum install -y curl policycoreutils openssh-server openssh-clients postfix systemctl start p ...