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 ...
随机推荐
- python3使用web.py遇到的找不属性的错误解决
今天用pyhon安装完web.py的时候,点击运行还是没错的,但是在网页输入链接就会报错.1.安装我是这样的: pip install web.py 2.运行后错误信息是这样: AttributeEr ...
- XCopy复制文件夹命令及参数详解以及xcopy拷贝目录并排除特定文件
XCOPY是COPY的扩展,可以把指定的目录连文件和目录结构一并拷贝,但不能拷贝系统文件:使用时源盘符.源目标路径名.源文件名至少指定一个:选用/S时对源目录下及其子目录下的所有文件进行COPY.除非 ...
- 2017多校第8场 HDU 6138 Fleet of the Eternal Throne 思维,暴力
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6138 题意:给了初始区间[-1,1],然后有一些操作,可以r加上一个数,l减掉一个数,或者同时操作,问 ...
- mybatis源码阅读(动态代理)
这一篇文章主要是记录Mybatis的动态代理学习成果,如果对源码感兴趣,可以看一下上篇文章 https://www.cnblogs.com/ChoviWu/p/10118051.html 阅读本篇的 ...
- java中的构造方法与其作用
什么是构造方法呢? 方法名和类名相同 没有返回值类型,连void都不能写 没有具体的返回值 构造方法分为无参构造方法与有参构造方法. 先来看一下最简单的无参构造方法: Student.java pac ...
- HDU-1083
Courses Time Limit: 20000/10000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total S ...
- 用matplotlib绘制漫画风格的图表
自从有了计算机,便很少有人手工绘制图表了.计算机绘制出的图表横平竖直,可以随意使用各种颜色,也完全不用担心画错需要重来的问题. 但有没有一种感觉,看多了工整的图表,变得有些审美疲劳.在各行各业逐渐过渡 ...
- linux下c获取时间
头文件 #include "sys/time.h" 结构体 struct timezone { int tz_minuteswest; /*格林威治时间往西方的时差*/ int t ...
- electron 编译 sqlite3避坑指南---尾部链接有已经编译成功的sqlite3
electron 编译 sqlite3避坑指南(尾部链接有已经编译成功的sqlite3) sqlite很好用,不需要安装,使用electron开发桌面程序,sqlite自然是存储数据的不二之选,奈何编 ...
- ejs模板在express里的默认文件夹路径修改
默认的是这句: app.set('view engine','ejs') ===>/views文件夹 我想要变成/websong app.set('views','webosg'); app.s ...