CSES - HIIT Open 2017 - Results
Submission details
Task:Dynamic duo
Sender:HIIT AND RUN
Submission time:2017-05-27 11:49:54 +0300
Language:C++
Status:READY
Result:ACCEPTED
Test results
testverdicttime
#1ACCEPTED0.03 sdetails
#2ACCEPTED0.07 sdetails
#3ACCEPTED0.05 sdetails
#4ACCEPTED0.06 sdetails
#5ACCEPTED0.04 sdetails
#6ACCEPTED0.07 sdetails
#7ACCEPTED0.05 sdetails
#8ACCEPTED0.04 sdetails
#9ACCEPTED0.05 sdetails
#10ACCEPTED0.05 sdetails
#11ACCEPTED0.06 sdetails
#12ACCEPTED0.05 sdetails
#13ACCEPTED0.04 sdetails
#14ACCEPTED0.05 sdetails
#15ACCEPTED0.04 sdetails
#16ACCEPTED0.03 sdetails
#17ACCEPTED0.04 sdetails
#18ACCEPTED0.04 sdetails
#19ACCEPTED0.05 sdetails
#20ACCEPTED0.06 sdetails
#21ACCEPTED0.05 sdetails
#22ACCEPTED0.04 sdetails
#23ACCEPTED0.05 sdetails
#24ACCEPTED0.04 sdetails
#25ACCEPTED0.06 sdetails
#26ACCEPTED0.06 sdetails
#27ACCEPTED0.05 sdetails
#28ACCEPTED0.07 sdetails
#29ACCEPTED0.06 sdetails
#30ACCEPTED0.04 sdetails
#31ACCEPTED0.05 sdetails
#32ACCEPTED0.05 sdetails
#33ACCEPTED0.05 sdetails
#34ACCEPTED0.05 sdetails
#35ACCEPTED0.04 sdetails
#36ACCEPTED0.04 sdetails
#37ACCEPTED0.05 sdetails
#38ACCEPTED0.04 sdetails
#39ACCEPTED0.05 sdetails
#40ACCEPTED0.05 sdetails
#41ACCEPTED0.04 sdetails
#42ACCEPTED0.06 sdetails
#43ACCEPTED0.04 sdetails
#44ACCEPTED0.06 sdetails
#45ACCEPTED0.05 sdetails
#46ACCEPTED0.04 sdetails
#47ACCEPTED0.05 sdetails

Compiler report

input/code.cpp: In function 'int main()':
input/code.cpp:18:17: warning: array subscript has type 'char' [-Wchar-subscripts]
         asd[s[i]]++; 
                 ^
input/code.cpp:32:21: warning: array subscript has type 'char' [-Wchar-subscripts]
         while (asd[i] > 0) {
                     ^
input/code.cpp:33:18: warning: array subscript has type 'char' [-Wchar-subscripts]
             asd[i]--;
                  ^
input/code.cpp:35:31: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
             if (a.size() == n/2) break;
                               ^
input/code.cpp:37:27: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         if (a.size() == n/2) break;
                           ^
input/code.cpp:42:21: warning: array subscript has type 'char' [-Wchar-subscripts]
         while (asd[i] > 0) {
                     ^
input/code.cpp:43:18: warning: array subscript has type 'char' [-Wchar-subscripts...

Code

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

int asd[256];

int main() {
    ios_base::sync_with_stdio(0);

    string s;
    cin >> s;
    ll n = s.size();
    


    for (int i = 0; i < n; i++) {
        asd[s[i]]++; 
    }
    
    for (int i = 0; i < 256; i++) {
        if (asd[i] > (n / 2)) {
            cout << "-1" << endl;
            return 0;
        }
    }
    
    string a = "";
    string b = "";
    
    for(char i = 'A'; i <= 'Z'; i++) {
        while (asd[i] > 0) {
            asd[i]--;
            a += i;
            if (a.size() == n/2) break;
        }
        if (a.size() == n/2) break;
    }
    
    
    for(char i = 'A'; i <= 'Z'; i++) {
        while (asd[i] > 0) {
            asd[i]--;
            b += i;
            if (b.size() == n/2) break;
        }
        if (b.size() == n/2) break;
    }

    cout << a << endl;
    cout << b << endl;
    
}

Test details

Test 1

Verdict: ACCEPTED

input
BA

correct output
A
B

user output
A
B

Test 2

Verdict: ACCEPTED

input
AA

correct output
-1

user output
-1

Test 3

Verdict: ACCEPTED

input
CAAB

correct output
AA
BC

user output
AA
BC

Test 4

Verdict: ACCEPTED

input
BABA

correct output
AA
BB

user output
AA
BB

Test 5

Verdict: ACCEPTED

input
BBCCAA

correct output
AAB
BCC

user output
AAB
BCC

Test 6

Verdict: ACCEPTED

input
AAAB

correct output
-1

user output
-1

Test 7

Verdict: ACCEPTED

input
BAABAC

correct output
AAA
BBC

user output
AAA
BBC

Test 8

Verdict: ACCEPTED

input
ABABAB

correct output
AAA
BBB

user output
AAA
BBB

Test 9

Verdict: ACCEPTED

input
BCBACAAB

correct output
AAAB
BBCC

user output
AAAB
BBCC

Test 10

Verdict: ACCEPTED

input
AAAA

correct output
-1

user output
-1

Test 11

Verdict: ACCEPTED

input
AABCAA

correct output
-1

user output
-1

Test 12

Verdict: ACCEPTED

input
AAABBA

correct output
-1

user output
-1

Test 13

Verdict: ACCEPTED

input
BBAACCAA

correct output
AAAA
BBCC

user output
AAAA
BBCC

Test 14

Verdict: ACCEPTED

input
ABAACBBA

correct output
AAAA
BBBC

user output
AAAA
BBBC

Test 15

Verdict: ACCEPTED

input
BBCCABAAAC

correct output
AAAAB
BBCCC

user output
AAAAB
BBCCC

Test 16

Verdict: ACCEPTED

input
BAAABABB

correct output
AAAA
BBBB

user output
AAAA
BBBB

Test 17

Verdict: ACCEPTED

input
CBBACABBAA

correct output
AAAAB
BBBCC

user output
AAAAB
BBBCC

Test 18

Verdict: ACCEPTED

input
BCACBAACBABC

correct output
AAAABB
BBCCCC

user output
AAAABB
BBCCCC

Test 19

Verdict: ACCEPTED

input
AAAABA

correct output
-1

user output
-1

Test 20

Verdict: ACCEPTED

input
BAAAACBA

correct output
-1

user output
-1

Test 21

Verdict: ACCEPTED

input
BBAAAABA

correct output
-1

user output
-1

Test 22

Verdict: ACCEPTED

input
BAACCBABAA

correct output
AAAAA
BBBCC

user output
AAAAA
BBBCC

Test 23

Verdict: ACCEPTED

input
BABACAABAB

correct output
AAAAA
BBBBC

user output
AAAAA
BBBBC

Test 24

Verdict: ACCEPTED

input
CCAABBABCBAA

correct output
AAAAAB
BBBCCC

user output
AAAAAB
BBBCCC

Test 25

Verdict: ACCEPTED

input
AABBAAABBB

correct output
AAAAA
BBBBB

user output
AAAAA
BBBBB

Test 26

Verdict: ACCEPTED

input
BABAACACBBAB

correct output
AAAAAB
BBBBCC

user output
AAAAAB
BBBBCC

Test 27

Verdict: ACCEPTED

input
AABBBCCABCABAC

correct output
AAAAABB
BBBCCCC

user output
AAAAABB
BBBCCCC

Test 28

Verdict: ACCEPTED

input
AAAAAA

correct output
-1

user output
-1

Test 29

Verdict: ACCEPTED

input
AABACAAA

correct output
-1

user output
-1

Test 30

Verdict: ACCEPTED

input
BAAABAAA

correct output
-1

user output
-1

Test 31

Verdict: ACCEPTED

input
ABAABAACAC

correct output
-1

user output
-1

Test 32

Verdict: ACCEPTED

input
AAAABACBBA

correct output
-1

user output
-1

Test 33

Verdict: ACCEPTED

input
BABCCBAACAAA

correct output
AAAAAA
BBBCCC

user output
AAAAAA
BBBCCC

Test 34

Verdict: ACCEPTED

input
BBBAAAABAA

correct output
-1

user output
-1

Test 35

Verdict: ACCEPTED

input
ABBABBAAACCA

correct output
AAAAAA
BBBBCC

user output
AAAAAA
BBBBCC

Test 36

Verdict: ACCEPTED

input
BCACABBACACABA

correct output
AAAAAAB
BBBCCCC

user output
AAAAAAB
BBBCCCC

Test 37

Verdict: ACCEPTED

input
BAABCBAAAABB

correct output
AAAAAA
BBBBBC

user output
AAAAAA
BBBBBC

Test 38

Verdict: ACCEPTED

input
ABBAACCABBCABA

correct output
AAAAAAB
BBBBCCC

user output
AAAAAAB
BBBBCCC

Test 39

Verdict: ACCEPTED

input
ABCACCBABBAACABC

correct output
AAAAAABB
BBBCCCCC

user output
AAAAAABB
BBBCCCCC

Test 40

Verdict: ACCEPTED

input
ABBBAAABBABA

correct output
AAAAAA
BBBBBB

user output
AAAAAA
BBBBBB

Test 41

Verdict: ACCEPTED

input
AAACAABBCABBBB

correct output
AAAAAAB
BBBBBCC

user output
AAAAAAB
BBBBBCC

Test 42

Verdict: ACCEPTED

input
BCBBBCAABABCCAAA

correct output
AAAAAABB
BBBBCCCC

user output
AAAAAABB
BBBBCCCC

Test 43

Verdict: ACCEPTED

input
BBCBAABACCCBAACACB

correct output
AAAAAABBB
BBBCCCCCC

user output
AAAAAABBB
BBBCCCCCC

Test 44

Verdict: ACCEPTED

input
BBABBABABAABAAABBAAABBBBBBAABB...

correct output
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA...

user output
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA...

Test 45

Verdict: ACCEPTED

input
AAAABABABBBBABAABBBABBBBBABBAB...

correct output
-1

user output
-1

Test 46

Verdict: ACCEPTED

input
ABBBAABAABAAABBAAAAABBBABAAAAB...

correct output
-1

user output
-1

Test 47

Verdict: ACCEPTED

input
XOQPQRNTLADFTEQSZYBMIRXWHSQDCM...

correct output
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA...

user output
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA...