CSES - Datatähti 2016 alku - Results
Submission details
Task:Osajono
Sender:Dentosal
Submission time:2015-09-29 13:09:33 +0300
Language:Python2
Status:READY
Result:0
Feedback
groupverdictscore
#10
#20
#30
Test results
testverdicttimegroup
#10.05 s1details
#2--1details
#30.05 s1details
#40.06 s1details
#50.05 s1details
#60.29 s2details
#70.43 s2details
#80.06 s2details
#90.06 s2details
#100.06 s2details
#110.64 s3details
#12--3details
#130.09 s3details
#140.09 s3details
#150.39 s3details

Code

# testing...
def group(s):
    r = [s[0]]
    for c in s[1:]:
        if c!=r[-1][0]:r.append("")
        r[-1]+=c
    return [len(q) for q in r]
def rm1(b,i):
    if i==0:        return b[1:]
    if i==len(b)-1: return b[:i]
    return b[:i-1]+[b[i-1]+b[i+1]]+b[i+2:]

# brute force
def solve(b):
    if len(b)==1:
        if b[0] < 2:
            return False, []
        else:
            return True, [0]
    q = [i for i,c in enumerate(b) if c>1]
    for w in q:
        s,r = solve(rm1(b,w))
        if s:
            return True, [w]+r
    return False, []


bits = group(raw_input())
s,r = solve(bits)
if s:
    print len(r)
    print " ".join([str(q+1) for q in r])
else:
    print "QAQ"

Test details

Test 1

Group: 1

Verdict:

input
BBBAABBBAAAABBAAAABAABAABBBBBB...

correct output
2554

user output
36
1 1 1 1 1 1 2 1 1 1 1 1 1 2 1 ...

Test 2

Group: 1

Verdict:

input
GDFVYWQCZAFGICSXOSWBZMGPDBSSVL...

correct output
299

user output
(empty)

Test 3

Group: 1

Verdict:

input
AAAAAAAAAAAAAAAAAAAAAAAAAZAAAA...

correct output
4314

user output
9
1 2 1 5 4 3 3 2 1

Test 4

Group: 1

Verdict:

input
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA...

correct output
4231

user output
13
1 1 1 2 1 1 2 1 1 2 2 1 1

Test 5

Group: 1

Verdict:

input
QQQQQQQQQQQQQQQQQQQQQQQQQQQQQQ...

correct output
5050

user output
1
1

Test 6

Group: 2

Verdict:

input
BBABABBBABBAABBABBABAABAAABABA...

correct output
6253029

user output
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 29, in <module>
    s,r = solve(bits)
  File "input/code.py", line 22, in solve
    s,r = solve(rm1(b,w))
  File "input/code.py", line 22, in solve
    s,r = solve(rm1(b,w))
  File "input/code.py", line 22, in solve
    s,r = solve(rm1(b,w))
  File "input/code.py", line 22, in solve
    s,r = solve(rm1(b,w))
  File "input/code.py", line 22, in solve
    s,r = solve(rm1(b,w))
  File "input/code.py", line 22, in solve
    s,r = solve(rm1(b,w))
  File "input/code.py", line 22, in solve
    s,r = solve(rm1(b,w))
  File "input/code.py", line 22, in solve
    s,r = solve(rm1(b,w))
  File "input/code.py", line 22, in solve
    s,r = solve(rm1(b,w))
  File "input/code.py", line 22, in solve
    s,r = solve(rm1(b,w))
  File "input/code.py", line 22, in solve
    s,r = solve(rm1(b,w))
  File "input/code.py", line 22, in solve
    s,r = solve(rm1(b,w))
  File "input/code.py", line 22, in solve
    s,r = solve(rm1(b,w))
  File "input/...

Test 7

Group: 2

Verdict:

input
RBKJMLDVQMKHYKCNDIVVKOMFUXTFMG...

correct output
485173

user output
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 29, in <module>
    s,r = solve(bits)
  File "input/code.py", line 22, in solve
    s,r = solve(rm1(b,w))
  File "input/code.py", line 22, in solve
    s,r = solve(rm1(b,w))
  File "input/code.py", line 22, in solve
    s,r = solve(rm1(b,w))
  File "input/code.py", line 22, in solve
    s,r = solve(rm1(b,w))
  File "input/code.py", line 22, in solve
    s,r = solve(rm1(b,w))
  File "input/code.py", line 22, in solve
    s,r = solve(rm1(b,w))
  File "input/code.py", line 22, in solve
    s,r = solve(rm1(b,w))
  File "input/code.py", line 22, in solve
    s,r = solve(rm1(b,w))
  File "input/code.py", line 22, in solve
    s,r = solve(rm1(b,w))
  File "input/code.py", line 22, in solve
    s,r = solve(rm1(b,w))
  File "input/code.py", line 22, in solve
    s,r = solve(rm1(b,w))
  File "input/code.py", line 22, in solve
    s,r = solve(rm1(b,w))
  File "input/code.py", line 22, in solve
    s,r = solve(rm1(b,w))
  File "input/...

Test 8

Group: 2

Verdict:

input
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA...

correct output
12427725

user output
23
1 2 1 1 2 1 1 2 1 1 2 1 1 2 1 ...

Test 9

Group: 2

Verdict:

input
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA...

correct output
12467549

user output
11
1 2 1 1 2 1 1 2 2 1 1

Test 10

Group: 2

Verdict:

input
QQQQQQQQQQQQQQQQQQQQQQQQQQQQQQ...

correct output
12502500

user output
1
1

Test 11

Group: 3

Verdict:

input
BAAAAABABBABAABAABABABBBABBAAB...

correct output
2500051369

user output
(empty)

Test 12

Group: 3

Verdict:

input
ABBURXDRVXAYBPXXOQZNYHLWGUEEWR...

correct output
192407124

user output
(empty)

Test 13

Group: 3

Verdict:

input
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA...

correct output
4998050400

user output
31
1 2 1 1 2 1 1 2 1 1 2 1 1 2 1 ...

Test 14

Group: 3

Verdict:

input
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA...

correct output
4998850144

user output
19
1 2 1 1 2 1 1 2 1 1 2 1 1 2 1 ...

Test 15

Group: 3

Verdict:

input
QQQQQQQQQQQQQQQQQQQQQQQQQQQQQQ...

correct output
5000050000

user output
1
1