Beruflich Dokumente
Kultur Dokumente
(/users/iamdivyansh)
Home (/) » Compete (/contests/) » March Lunchtime 2018 Division 2 (/LTIME58B) » Partitions
(http://www.codechef.com/download/translated/LTIME58/russian/ARRP.pdf)
and Vietnamese
(http://www.codechef.com/download/translated/LTIME58/vietnamese/ARRP.pdf)
as well.
You are given an array A with size N. For each K between 1 and N (inclusive), find out if
it is possible to partition (split) the array A into K contiguous subarrays such that the sum
of elements within each of these subarrays is the same. Each element of the original
array should belong to exactly one subarray.
Input
The first line of the input contains a single integer T denoting the number of test
cases. The description of T test cases follows.
The first line of each test case contains a single integer N.
The second line contains N space-separated integers A1, A2, ..., AN.
Output
For each test case, print a single line containing N characters. For each K (1 ≤ K ≤ N),
the K-th of these characters should be '1' if it is possible to partition the array in the
desired way or '0' if it is impossible.
Constraints
1 ≤ T ≤ 1,000,000
1 ≤ N ≤ 1,000,000
1 ≤ sum of N over all test cases ≤ 1,000,000
1 ≤ Ai ≤ 109 for each valid i
Subtasks
Subtask #1 (30 points): sum of N over all test cases ≤ 10,000
Example
Input:
3
5
1 4 2 3 5
4
1 1 1 1
4
1 1 2 2
Output:
10100
1101
1010
Explanation
Example case 1: There are two possible partitions: into exactly 1 array (with sum
1+4+3+2+5) or into exactly 3 arrays (with sums 1+4 = 2+3 = 5).
Languages: C, CPP14, JAVA, PYTH, PYTH 3.5, PYPY, CS2, PAS fpc, PAS gpc,
RUBY, PHP, GO, NODEJS, HASK, rust, SCALA, swift, D, PERL,
FORT, WSPC, ADA, CAML, ICK, BF, ASM, CLPS, PRLG, ICON,
SCM qobi, PIKE, ST, NICE, LUA, BASH, NEM, LISP sbcl, LISP
clisp, SCM guile, JS, ERL, TCL, kotlin, PERL6, TEXT, SCM chicken,
CLOJ, COB, FS
Submit (/LTIME58B/submit/ARRP)
Comments
© 2009 Directi Group (http://directi.com). All Rights Reserved. CodeChef uses SPOJ © by Sphere Research Labs (http://www.sphere-research.com)
In order to report copyright violations of any kind, send in an email to copyright@codechef.com (mailto:copyright@codechef.com)
(http://directi.com)
FAQ's (https://www.codechef.com/wiki/faq)
Initiatives