CSES - Datatähti 2018 alku - Results
Submission details
Task:Merkkijono
Sender:inkeri
Submission time:2017-10-10 22:16:08 +0300
Language:Python3
Status:READY
Result:0
Feedback
groupverdictscore
#10
Test results
testverdicttime
#10.08 sdetails
#20.07 sdetails
#30.06 sdetails
#40.09 sdetails
#50.07 sdetails
#60.08 sdetails
#70.07 sdetails
#80.07 sdetails
#90.07 sdetails
#100.07 sdetails

Code

#stringBuilder?

def main():
    tavoite = int(input())
    jono = lyhinjono(tavoite, [1], 1, 2, 1)
    bittijono = ""
    edellinenBitti = "0"
    edellinenLuku = 0
    for luku in jono:
        if luku == edellinenLuku:
            bittijono += edellinenBitti
        else:
            edellinenLuku = luku
            if edellinenBitti == "0":
                bittijono += "1"
                edellinenBitti = "1"
            else:
                bittijono += "0"
                edellinenBitti = "0"
    print(bittijono)

#tavoite: tavoiteltava summa
#tähän asti lisätyt luvut
#viimeinen: listan viimeinen luku
#summa: lisättävä summa jos lisätään eri luku kuin viimeinen
#kokonaisSumma: listan kokonaisSumma
def lyhinjono(tavoite, lista, viimeinen, summa, kokonaisSumma):
    if kokonaisSumma == tavoite:
        return lista
    if kokonaisSumma > tavoite:
        return False
    #lisätään eri luku, jolloin arvo kasvaa summalla
    jono = lyhinjono(tavoite, lista + [summa], summa, summa + viimeinen, kokonaisSumma + summa)
    if jono:
        return jono
    #lisätään sama luku kuin edellinen, arvo kasvaa listan viimeisellä
    return lyhinjono(tavoite, lista + [viimeinen], viimeinen, summa + viimeinen, kokonaisSumma + viimeinen)

main()

Test details

Test 1

Verdict:

input
ABABABABABABABABABABABABABABAB...

correct output
ABABABABABABABABABABABABABABAB...

user output
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 39, in <module>
    main()
  File "input/code.py", line 4, in main
    tavoite = int(input())
ValueError: invalid literal for int() with base 10: 'ABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABA

Test 2

Verdict:

input
AABBAABBAABBAABBAABBAABBAABBAA...

correct output
(empty)

user output
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 39, in <module>
    main()
  File "input/code.py", line 4, in main
    tavoite = int(input())
ValueError: invalid literal for int() with base 10: 'AABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAAB

Test 3

Verdict:

input
ABABABABABABABABABABABABABABAB...

correct output
(empty)

user output
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 39, in <module>
    main()
  File "input/code.py", line 4, in main
    tavoite = int(input())
ValueError: invalid literal for int() with base 10: 'ABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABA

Test 4

Verdict:

input
BBABABBBBBAABBBABABABBBBAAABAB...

correct output
BAB

user output
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 39, in <module>
    main()
  File "input/code.py", line 4, in main
    tavoite = int(input())
ValueError: invalid literal for int() with base 10: 'BBABABBBBBAABBBABABABBBBAAABABAABBBBBABBAABABABAABABAABABAABBAAABBABAABAAABABAAABAABBAABBABABBABBABBAAABBBBABBABBBABBAAABBBAAAABABABAABAABBAAAAABABBABABABBABBBBAABBBABBBAABBBABAABBABBBAAABBAAAAABAABA

Test 5

Verdict:

input
ACDCBBACDBBBACAACBBDBADBAABABA...

correct output
ACDCACDADBADABACACDCADADABABCA...

user output
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 39, in <module>
    main()
  File "input/code.py", line 4, in main
    tavoite = int(input())
ValueError: invalid literal for int() with base 10: 'ACDCBBACDBBBACAACBBDBADBAABABACACDAACADADABABCACBCBCBCADDBABCCCDCBDBACDCDCCCCACAACDBABAAADDDBAADABBBCDADAADCDBDBCBDACBABDBCBCBBCACCDDBBCDCBDCDCAADACACABADBDAADBABCDABBBBABBCAADABDABCAAABDBBBBACACBCDC

Test 6

Verdict:

input
EETFHIJOGACDHMGVFJCMETMZDEITTR...

correct output
TFHIJOGACDHMGVFJCMETMZDEIROTET...

user output
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 39, in <module>
    main()
  File "input/code.py", line 4, in main
    tavoite = int(input())
ValueError: invalid literal for int() with base 10: 'EETFHIJOGACDHMGVFJCMETMZDEITTROTETBSAQREWKXSUQRTJSTMAYKWXMHMMWBRVLIVCGSTGYQJUYYSGWQSDQMHWXNSYPPOIQTIHWMUYRDINAAIUORGPINGWFDQAMBUNDKSQPRPWNQJYZMTJGPTFPCZZPGIVYURCHDHEMWVZDLEOKVCDKWSILOJXDERMWOHLUYRDZN

Test 7

Verdict:

input
GOONLAHLYPRFCZKIKSJWAWWYJJPCDB...

correct output
GNLAHLYPRFCZKIKSJWAYPCDNWYMRCE...

user output
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 39, in <module>
    main()
  File "input/code.py", line 4, in main
    tavoite = int(input())
ValueError: invalid literal for int() with base 10: 'GOONLAHLYPRFCZKIKSJWAWWYJJPCDBBNWYMRCEHGRBLZOOZXEHVPDFXVCTWAWJTYSQHCYPQVKJOZRQUBAYVQHIWGJBXFKJIDDSAWEXWQGBTNMKQHKTXAAZVKKYTKFYGGFWXOVSHMDPQJOHCVVIFGVMSKWFIAUZSFLDFTFDJYRQXCDLFVHCWHCTPYWYDEESTZVZMRYUW

Test 8

Verdict:

input
PISHWMOTCDDZFRMYMOMYDYYGJZIQHS...

correct output
PISHWMOTCZFRMYMOMYDGJZIQHSVAOK...

user output
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 39, in <module>
    main()
  File "input/code.py", line 4, in main
    tavoite = int(input())
ValueError: invalid literal for int() with base 10: 'PISHWMOTCDDZFRMYMOMYDYYGJZIQHSPPVAOKCVWVNOFCVIDUKPNVKSWMAGEUUZDKABCGEOWKFFWVLKINEWFSBODTECTFDVIMLZDVJQVNHIYAAXOLWCDLYDTNRBWMPTLWWFMSXTVEZPGCPOMOHXULJNZLVIPQANEVHKKZBUVTDDGSBVRFCXSTOTMQJUVBPHWVAXNIPOR

Test 9

Verdict:

input
QUVVTPXAMWWODFXRONJODPGBTCISGM...

correct output
QUTPXAMODFXRONJODPGBTCISGMVRBW...

user output
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 39, in <module>
    main()
  File "input/code.py", line 4, in main
    tavoite = int(input())
ValueError: invalid literal for int() with base 10: 'QUVVTPXAMWWODFXRONJODPGBTCISGMVWWRBWRZHKKLAFTQABFHFWMFNTZPSAWUDLABCXURSULRAOGBABUWOMDITAGQOYPUEZEPRGWOOAQFLHGQTHZNUUFSCNDCRXVNXMROXDXEYYJJRHZPESKGUMPLOYLKVNDLSNUYFHAUOQKUFKFQDVGNOOLEMDCVPQYEAXMBJIWWX

Test 10

Verdict:

input
POXHAHYEZTLYNFSLABODMRNKDSKROZ...

correct output
POXHAHYEZTLYNFSLABODMRNKDSKROZ...

user output
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 39, in <module>
    main()
  File "input/code.py", line 4, in main
    tavoite = int(input())
ValueError: invalid literal for int() with base 10: 'POXHAHYEZTLYNFSLABODMRNKDSKROZWJCEHBGGTIQBYGWGOLUPTJKMXGIBMBJRGQUGDKEKFTZNOYGRTOPJPLEHWXCPOOUHPPIQNJZUFRHPLTYBULNLCLYEXSASENZOSLVZGKBLNRWDNZDWGRLVJKCPKSXJWRZCXOHPTDQDWPEORPCRUZDGMMTOOKTQBCBZIXNTQSMPD