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 ...
随机推荐
- XCopy复制文件夹命令及参数详解以及xcopy拷贝目录并排除特定文件
XCOPY是COPY的扩展,可以把指定的目录连文件和目录结构一并拷贝,但不能拷贝系统文件:使用时源盘符.源目标路径名.源文件名至少指定一个:选用/S时对源目录下及其子目录下的所有文件进行COPY.除非 ...
- 访问WEB-INF目录中的文件
WEB-INF下面的文件具有安全性,直接在浏览器中输入地址是访问不到的,可以通过servlet来访问. 方法1: 利用<jsp-file>/WEB-INF/a.jsp</jsp-fi ...
- linux sftp and unix ftp
sftp 1.功能作用 sftp 是一个交互式文件传输程式.它类似于 ftp, 但它进行加密传输,比FTP有更高的安全性. 2.位置 /usr/bin/sftp 3.格式用法 sftp [-1246C ...
- Mui自定义时间格式:
Mui自定义时间格式: (function($) { $.init(); $(document).on('tap','.btn',function(){ var obj = getFormJson($ ...
- leetcode 141 142. Linked List Cycle
题目描述: 不用辅助空间判断,链表中是否有环 /** * Definition for singly-linked list. * struct ListNode { * int val; * Lis ...
- Leetcode 之Binary Tree Postorder Traversal(46)
采用广度优先遍历,一个变量记录层数,一个变量记录方向. void traverse(TreeNode *root, vector<vector<int>> result, in ...
- 《深入浅出MyBatis技术原理与实战》——7. 插件
在第6章讨论了四大运行对象的运行过程,在Configuration对象的创建方法里我们看到了MyBatis用责任链去封装它们. 7.1 插件接口 在MyBatis中使用插件,我们必须使用接口Inter ...
- 前后端分离,Vue+restfullframework
一.准备 修改源: npm config set registry https://registry.npm.taobao.org 创建脚手架: vue init webpack Vue项目名称 #I ...
- Jquery当div超出页面时就固定到顶部否则跟随页面滚动
$.fn.smartFloat = function () { var position = function (element) { var top = element.position().top ...
- AC日记——明明的烦恼 bzoj 1005
1005 思路: prufer编码+组合数: 代码: #include <bits/stdc++.h> using namespace std; #define maxn 1005 #de ...