Code Submission Evaluation System Login

HIIT Open 2017

Start:2017-05-27 11:00:00
End:2017-05-27 16:00:00
 

Tasks | Messages | Scoreboard | Statistics


CSES - HIIT Open 2017 - Results
History
2017-05-27 11:37:15
Task:Dynamic duo
Sender:Kanadan virallinen maajoukkue
Submission time:2017-05-27 11:37:15
Language:C++
Status:READY
Result:ACCEPTED

Test results

testverdicttime (s)
#1ACCEPTED0.04 / 1.00details
#2ACCEPTED0.09 / 1.00details
#3ACCEPTED0.05 / 1.00details
#4ACCEPTED0.05 / 1.00details
#5ACCEPTED0.06 / 1.00details
#6ACCEPTED0.05 / 1.00details
#7ACCEPTED0.04 / 1.00details
#8ACCEPTED0.04 / 1.00details
#9ACCEPTED0.05 / 1.00details
#10ACCEPTED0.05 / 1.00details
#11ACCEPTED0.03 / 1.00details
#12ACCEPTED0.04 / 1.00details
#13ACCEPTED0.07 / 1.00details
#14ACCEPTED0.06 / 1.00details
#15ACCEPTED0.04 / 1.00details
#16ACCEPTED0.04 / 1.00details
#17ACCEPTED0.05 / 1.00details
#18ACCEPTED0.05 / 1.00details
#19ACCEPTED0.05 / 1.00details
#20ACCEPTED0.05 / 1.00details
#21ACCEPTED0.07 / 1.00details
#22ACCEPTED0.05 / 1.00details
#23ACCEPTED0.03 / 1.00details
#24ACCEPTED0.05 / 1.00details
#25ACCEPTED0.05 / 1.00details
#26ACCEPTED0.04 / 1.00details
#27ACCEPTED0.04 / 1.00details
#28ACCEPTED0.05 / 1.00details
#29ACCEPTED0.08 / 1.00details
#30ACCEPTED0.05 / 1.00details
#31ACCEPTED0.04 / 1.00details
#32ACCEPTED0.04 / 1.00details
#33ACCEPTED0.06 / 1.00details
#34ACCEPTED0.04 / 1.00details
#35ACCEPTED0.07 / 1.00details
#36ACCEPTED0.05 / 1.00details
#37ACCEPTED0.05 / 1.00details
#38ACCEPTED0.02 / 1.00details
#39ACCEPTED0.05 / 1.00details
#40ACCEPTED0.05 / 1.00details
#41ACCEPTED0.05 / 1.00details
#42ACCEPTED0.05 / 1.00details
#43ACCEPTED0.03 / 1.00details
#44ACCEPTED0.12 / 1.00details
#45ACCEPTED0.11 / 1.00details
#46ACCEPTED0.10 / 1.00details
#47ACCEPTED0.15 / 1.00details

Compiler report

input/code.cpp: In function 'int main()':
input/code.cpp:11:29: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i=0; i<s.length(); i++)
                             ^
input/code.cpp:12:17: warning: array subscript has type 'char' [-Wchar-subscripts]
         cnt[s[i]]++;
                 ^
input/code.cpp:18:17: warning: array subscript has type 'char' [-Wchar-subscripts]
         if(cnt[c]>0)
                 ^
input/code.cpp:19:36: warning: array subscript has type 'char' [-Wchar-subscripts]
             pq.push(make_pair(cnt[c],c));
                                    ^

Code

#include<iostream>
#include<queue>

using namespace std;

int cnt[256];

int main(){
    string s;
    cin>>s;
    for(int i=0; i<s.length(); i++)
        cnt[s[i]]++;
        
    string a,b;
    priority_queue<pair<int, char>> pq;
    
    for(char c='A'; c<='Z'; c++)
        if(cnt[c]>0)
            pq.push(make_pair(cnt[c],c));
    
    while(pq.size()){
        if(pq.size()==1){
            cout<<-1<<endl;
            return 0;
        }
        
        pair<int,char> p1,p2;
        p1=pq.top();
        pq.pop();
        p2=pq.top();
        pq.pop();
        
        a+=p1.second;
        b+=p2.second;
        
        p1.first--;
        p2.first--;
        
        if(p1.first>0)
            pq.push(p1);
        if(p2.first>0)
            pq.push(p2);
    }
    
    
    cout<<a<<endl;
    cout<<b<<endl;
    return 0;
}

Test details

Test 1

Verdict: ACCEPTED

input
BA
view   save

correct output
A
B
view   save

user output
B
A
view   save

Test 2

Verdict: ACCEPTED

input
AA
view   save

correct output
-1
view   save

user output
-1
view   save

Test 3

Verdict: ACCEPTED

input
CAAB
view   save

correct output
AA
BC
view   save

user output
AB
CA
view   save

Test 4

Verdict: ACCEPTED

input
BABA
view   save

correct output
AA
BB
view   save

user output
BB
AA
view   save

Test 5

Verdict: ACCEPTED

input
BBCCAA
view   save

correct output
AAB
BCC
view   save

user output
CAB
BCA
view   save

Test 6

Verdict: ACCEPTED

input
AAAB
view   save

correct output
-1
view   save

user output
-1
view   save

Test 7

Verdict: ACCEPTED

input
BAABAC
view   save

correct output
AAA
BBC
view   save

user output
AAB
BCA
view   save

Test 8

Verdict: ACCEPTED

input
ABABAB
view   save

correct output
AAA
BBB
view   save

user output
BBB
AAA
view   save

Test 9

Verdict: ACCEPTED

input
BCBACAAB
view   save

correct output
AAAB
BBCC
view   save

user output
BCAB
ABCA
view   save

Test 10

Verdict: ACCEPTED

input
AAAA
view   save

correct output
-1
view   save

user output
-1
view   save

Test 11

Verdict: ACCEPTED

input
AABCAA
view   save

correct output
-1
view   save

user output
-1
view   save

Test 12

Verdict: ACCEPTED

input
AAABBA
view   save

correct output
-1
view   save

user output
-1
view   save

Test 13

Verdict: ACCEPTED

input
BBAACCAA
view   save

correct output
AAAA
BBCC
view   save

user output
AAAB
CBCA
view   save

Test 14

Verdict: ACCEPTED

input
ABAACBBA
view   save

correct output
AAAA
BBBC
view   save

user output
AAAB
BBCA
view   save

Test 15

Verdict: ACCEPTED

input
BBCCABAAAC
view   save

correct output
AAAAB
BBCCC
view   save

user output
ABCAB
CABCA
view   save

Test 16

Verdict: ACCEPTED

input
BAAABABB
view   save

correct output
AAAA
BBBB
view   save

user output
BBBB
AAAA
view   save

Test 17

Verdict: ACCEPTED

input
CBBACABBAA
view   save

correct output
AAAAB
BBBCC
view   save

user output
BBCAB
AABCA
view   save

Test 18

Verdict: ACCEPTED

input
BCACBAACBABC
view   save

correct output
AAAABB
BBCCCC
view   save

user output
CABCAB
BCABCA
view   save

Test 19

Verdict: ACCEPTED

input
AAAABA
view   save

correct output
-1
view   save

user output
-1
view   save

Test 20

Verdict: ACCEPTED

input
BAAAACBA
view   save

correct output
-1
view   save

user output
-1
view   save

Test 21

Verdict: ACCEPTED

input
BBAAAABA
view   save

correct output
-1
view   save

user output
-1
view   save

Test 22

Verdict: ACCEPTED

input
BAACCBABAA
view   save

correct output
AAAAA
BBBCC
view   save

user output
AAAAB
BCBCA
view   save

Test 23

Verdict: ACCEPTED

input
BABACAABAB
view   save

correct output
AAAAA
BBBBC
view   save

user output
AAAAB
BBBCA
view   save

Test 24

Verdict: ACCEPTED

input
CCAABBABCBAA
view   save

correct output
AAAAAB
BBBCCC
view   save

user output
AABCAB
BCABCA
view   save

Test 25

Verdict: ACCEPTED

input
AABBAAABBB
view   save

correct output
AAAAA
BBBBB
view   save

user output
BBBBB
AAAAA
view   save

Test 26

Verdict: ACCEPTED

input
BABAACACBBAB
view   save

correct output
AAAAAB
BBBBCC
view   save

user output
BBBCAB
AAABCA
view   save

Test 27

Verdict: ACCEPTED

input
AABBBCCABCABAC
view   save

correct output
AAAAABB
BBBCCCC
view   save

user output
BCABCAB
ABCABCA
view   save

Test 28

Verdict: ACCEPTED

input
AAAAAA
view   save

correct output
-1
view   save

user output
-1
view   save

Test 29

Verdict: ACCEPTED

input
AABACAAA
view   save

correct output
-1
view   save

user output
-1
view   save

Test 30

Verdict: ACCEPTED

input
BAAABAAA
view   save

correct output
-1
view   save

user output
-1
view   save

Test 31

Verdict: ACCEPTED

input
ABAABAACAC
view   save

correct output
-1
view   save

user output
-1
view   save

Test 32

Verdict: ACCEPTED

input
AAAABACBBA
view   save

correct output
-1
view   save

user output
-1
view   save

Test 33

Verdict: ACCEPTED

input
BABCCBAACAAA
view   save

correct output
AAAAAA
BBBCCC
view   save

user output
AAAAAB
CBCBCA
view   save

Test 34

Verdict: ACCEPTED

input
BBBAAAABAA
view   save

correct output
-1
view   save

user output
-1
view   save

Test 35

Verdict: ACCEPTED

input
ABBABBAAACCA
view   save

correct output
AAAAAA
BBBBCC
view   save

user output
AAAAAB
BBCBCA
view   save

Test 36

Verdict: ACCEPTED

input
BCACABBACACABA
view   save

correct output
AAAAAAB
BBBCCCC
view   save

user output
AAABCAB
CBCABCA
view   save

Test 37

Verdict: ACCEPTED

input
BAABCBAAAABB
view   save

correct output
AAAAAA
BBBBBC
view   save

user output
AAAAAB
BBBBCA
view   save

Test 38

Verdict: ACCEPTED

input
ABBAACCABBCABA
view   save

correct output
AAAAAAB
BBBBCCC
view   save

user output
AAABCAB
BBCABCA
view   save

Test 39

Verdict: ACCEPTED

input
ABCACCBABBAACABC
view   save

correct output
AAAAAABB
BBBCCCCC
view   save

user output
ABCABCAB
CABCABCA
view   save

Test 40

Verdict: ACCEPTED

input
ABBBAAABBABA
view   save

correct output
AAAAAA
BBBBBB
view   save

user output
BBBBBB
AAAAAA
view   save

Test 41

Verdict: ACCEPTED

input
AAACAABBCABBBB
view   save

correct output
AAAAAAB
BBBBBCC
view   save

user output
BBBBCAB
AAAABCA
view   save

Test 42

Verdict: ACCEPTED

input
BCBBBCAABABCCAAA
view   save

correct output
AAAAAABB
BBBBCCCC
view   save

user output
BBCABCAB
AABCABCA
view   save

Test 43

Verdict: ACCEPTED

input
BBCBAABACCCBAACACB
view   save

correct output
AAAAAABBB
BBBCCCCCC
view   save

user output
CABCABCAB
BCABCABCA
view   save

Test 44

Verdict: ACCEPTED

input
BBABBABABAABAAABBAAABBBBBBAABB...
view   save

correct output
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA...
view   save

user output
BBBBBBBBBBBBBBBBBBBBBBBBBBBBBB...
view   save

Test 45

Verdict: ACCEPTED

input
AAAABABABBBBABAABBBABBBBBABBAB...
view   save

correct output
-1
view   save

user output
-1
view   save

Test 46

Verdict: ACCEPTED

input
ABBBAABAABAAABBAAAAABBBABAAAAB...
view   save

correct output
-1
view   save

user output
-1
view   save

Test 47

Verdict: ACCEPTED

input
XOQPQRNTLADFTEQSZYBMIRXWHSQDCM...
view   save

correct output
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA...
view   save

user output
QQQQQQQQQQQQQQQQQQQQQQQQQQQQQQ...
view   save