编程介的小学生 2020-02-15 19:53 采纳率: 20.5%
浏览 71

Unshuffle 洗牌问题

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.

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.

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
1
8
1 2 3 1 2 4 3 4

Sample Output
00011011

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 oracle集群安装出bug
    • ¥15 关于#python#的问题:自动化测试
    • ¥20 问题请教!vue项目关于Nginx配置nonce安全策略的问题
    • ¥15 教务系统账号被盗号如何追溯设备
    • ¥20 delta降尺度方法,未来数据怎么降尺度
    • ¥15 c# 使用NPOI快速将datatable数据导入excel中指定sheet,要求快速高效
    • ¥15 再不同版本的系统上,TCP传输速度不一致
    • ¥15 高德地图2.0 版本点聚合中Marker的位置无法实时更新,如何解决呢?
    • ¥15 DIFY API Endpoint 问题。
    • ¥20 sub地址DHCP问题