多校练习赛6 HDU4605 unshuffle
来源:互联网 发布:树脂镜片 保质期 知乎 编辑:程序博客网 时间:2024/06/05 09:39
Unshuffle
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 433 Accepted Submission(s): 151
Special Judge
Problem Description
A 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.
Given a square string, in which each character occurs no more than four times, unshuffle it into two identical strings.
Input
First line, number of test cases, T.
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.
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.
Output
T 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.
Sample Input
181 2 3 1 2 4 3 4
Sample Output
00011011
Source
2013 Multi-University Training Contest 6
Recommend
zhuyuanchen520
其实这道很无语。。 当时看过的人太少。。估计是被多校给整怕了。题都不敢尝试。 没想到诶。 竟然 暴搜78MS就过掉了。 看题解是用的2-SAT,表示淡淡的忧伤。
多校的第一题也是。公式都推出来了。竟然是数组开太小了。 看来是自己心理素质不够强。 多尝试就好了。用不同的方法,总会过去的。以后做题得勇敢点了。
一步一个脚印,就当被上了堂课。 人生也该是如此吧。多尝试,不要拘泥,不要害怕。。
暴搜。。没什么好讲的。。。就是开数组存个答案。
#include <cstdio>#include <cstdlib>int n;char ans[4000];int s[4000];int a[4000];bool flag;void dfs(int x,int y,int step){ if(flag) return; if(x>(n>>1)||y>(n>>1)) return; if(step==n){ flag=true; return; } ans[step]='0'; s[x]=a[step]; dfs(x+1,y,step+1); if(flag) return; if(s[y]==a[step]){ ans[step]='1'; dfs(x,y+1,step+1); }}int main(){ int t; scanf("%d",&t); while(t--){ scanf("%d",&n); for(int i=0;i<n;i++){ scanf("%d",a+i); } flag=false; dfs(0,0,0); for(int i=0;i<n;i++) printf("%c",ans[i]); printf("\n"); } return 0;}
- 多校练习赛6 HDU4605 unshuffle
- 多校第一场——hdu4605——离线
- 2013 多校第六场 hdu 4665 Unshuffle
- hdu4665 Unshuffle
- hdu4605 Magic Ball Game
- hdu4605 线段树+dfs
- 树状数组+离线+hdu4605
- HDU4605-Magic Ball Game
- hdu 4665 Unshuffle (DFS)
- HDU 4665 Unshuffle
- hdu 4665 Unshuffle
- hdu - 4665 - Unshuffle
- hdu 4665Unshuffle
- Unshuffle(深搜加剪枝-hdu4665)
- hdu 4665 Unshuffle(暴力)
- hdu4605 树状数组+离散化+dfs
- hdu4605 Magic Ball Game(树状数组)
- 多校联合练习赛6 HDU 4655 Cut Pierces
- 如何在service中弹出dialog
- Android中如何修改系统时间
- CKedit简介
- Struts2 学习笔记13 OGNL part2
- The entity "nbsp" was referenced, but not declared
- 多校练习赛6 HDU4605 unshuffle
- php var_export与var_dump 输出的不同
- ubuntu qt 5.1 正式版 安卓开发环境搭建
- emacs学习笔记
- 指向指针的指针的作用
- hdu 4405 Aeroplane chess
- POJ-滑雪-(java,搜索)
- 和老BIOS说永别 EFI BIOS技术解析
- P08泛化物品的背包问题