Task: | Dynamic duo |
Sender: | KnowYourArchitecture |
Submission time: | 2017-05-27 11:47:28 +0300 |
Language: | C++ |
Status: | READY |
Result: | ACCEPTED |
test | verdict | time | |
---|---|---|---|
#1 | ACCEPTED | 0.04 s | details |
#2 | ACCEPTED | 0.06 s | details |
#3 | ACCEPTED | 0.06 s | details |
#4 | ACCEPTED | 0.04 s | details |
#5 | ACCEPTED | 0.03 s | details |
#6 | ACCEPTED | 0.06 s | details |
#7 | ACCEPTED | 0.06 s | details |
#8 | ACCEPTED | 0.05 s | details |
#9 | ACCEPTED | 0.04 s | details |
#10 | ACCEPTED | 0.03 s | details |
#11 | ACCEPTED | 0.07 s | details |
#12 | ACCEPTED | 0.06 s | details |
#13 | ACCEPTED | 0.04 s | details |
#14 | ACCEPTED | 0.06 s | details |
#15 | ACCEPTED | 0.07 s | details |
#16 | ACCEPTED | 0.03 s | details |
#17 | ACCEPTED | 0.04 s | details |
#18 | ACCEPTED | 0.04 s | details |
#19 | ACCEPTED | 0.07 s | details |
#20 | ACCEPTED | 0.04 s | details |
#21 | ACCEPTED | 0.04 s | details |
#22 | ACCEPTED | 0.05 s | details |
#23 | ACCEPTED | 0.05 s | details |
#24 | ACCEPTED | 0.02 s | details |
#25 | ACCEPTED | 0.06 s | details |
#26 | ACCEPTED | 0.05 s | details |
#27 | ACCEPTED | 0.03 s | details |
#28 | ACCEPTED | 0.04 s | details |
#29 | ACCEPTED | 0.04 s | details |
#30 | ACCEPTED | 0.05 s | details |
#31 | ACCEPTED | 0.04 s | details |
#32 | ACCEPTED | 0.03 s | details |
#33 | ACCEPTED | 0.05 s | details |
#34 | ACCEPTED | 0.05 s | details |
#35 | ACCEPTED | 0.04 s | details |
#36 | ACCEPTED | 0.03 s | details |
#37 | ACCEPTED | 0.04 s | details |
#38 | ACCEPTED | 0.05 s | details |
#39 | ACCEPTED | 0.05 s | details |
#40 | ACCEPTED | 0.04 s | details |
#41 | ACCEPTED | 0.04 s | details |
#42 | ACCEPTED | 0.03 s | details |
#43 | ACCEPTED | 0.05 s | details |
#44 | ACCEPTED | 0.08 s | details |
#45 | ACCEPTED | 0.06 s | details |
#46 | ACCEPTED | 0.05 s | details |
#47 | ACCEPTED | 0.10 s | details |
Compiler report
input/code.cpp: In function 'int main()': input/code.cpp:18:14: warning: array subscript has type 'char' [-Wchar-subscripts] cnt[c] += 1; ^ input/code.cpp:19:17: warning: array subscript has type 'char' [-Wchar-subscripts] if(cnt[c] > nn) { ^ input/code.cpp:35:18: warning: array subscript has type 'char' [-Wchar-subscripts] if(!cnt[c]) continue; ^ input/code.cpp:39:28: warning: array subscript has type 'char' [-Wchar-subscripts] for(int i=0;i<cnt[c];i++) { ^
Code
#include <bits/stdc++.h> using namespace std; int cnt[200]; int main() { cin.tie(0); ios::sync_with_stdio(false); string s; cin >> s; int n = s.length(); int nn = n/2; for(auto c : s) { cnt[c] += 1; if(cnt[c] > nn) { cout << -1 << endl; return 0; } } //for(char c = 'A'; c <= 'Z'; c++) cout << c << ": " << cnt[c] << endl; vector<char> A(nn, '*'), B(nn, '*'); bool a = true; int idx = 0; for(char c = 'A'; c <= 'Z'; c++) { // find first empty in A/B if(!cnt[c]) continue; // cout << c << ": " << idx << ", " << a << endl; for(int i=0;i<cnt[c];i++) { if(a) { A[idx] = c; } else { B[idx] = c; } idx++; a = !a; if(idx >= nn) { idx = 0; a = false; } } } for(int i=0;i<nn;i++) { cout << A[i]; } cout << endl; for(int i=0;i<nn;i++) { cout << B[i]; } cout << endl; return 0; }
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 |
---|
AC BA |
Test 4
Verdict: ACCEPTED
input |
---|
BABA |
correct output |
---|
AA BB |
user output |
---|
AB BA |
Test 5
Verdict: ACCEPTED
input |
---|
BBCCAA |
correct output |
---|
AAB BCC |
user output |
---|
ACB BAC |
Test 6
Verdict: ACCEPTED
input |
---|
AAAB |
correct output |
---|
-1 |
user output |
---|
-1 |
Test 7
Verdict: ACCEPTED
input |
---|
BAABAC |
correct output |
---|
AAA BBC |
user output |
---|
ABA BAC |
Test 8
Verdict: ACCEPTED
input |
---|
ABABAB |
correct output |
---|
AAA BBB |
user output |
---|
ABA BAB |
Test 9
Verdict: ACCEPTED
input |
---|
BCBACAAB |
correct output |
---|
AAAB BBCC |
user output |
---|
ABAC BACB |
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 |
---|
ABAC BACA |
Test 14
Verdict: ACCEPTED
input |
---|
ABAACBBA |
correct output |
---|
AAAA BBBC |
user output |
---|
ABAC BABA |
Test 15
Verdict: ACCEPTED
input |
---|
BBCCABAAAC |
correct output |
---|
AAAAB BBCCC |
user output |
---|
ABACB BACAC |
Test 16
Verdict: ACCEPTED
input |
---|
BAAABABB |
correct output |
---|
AAAA BBBB |
user output |
---|
ABAB BABA |
Test 17
Verdict: ACCEPTED
input |
---|
CBBACABBAA |
correct output |
---|
AAAAB BBBCC |
user output |
---|
ABACB BABAC |
Test 18
Verdict: ACCEPTED
input |
---|
BCACBAACBABC |
correct output |
---|
AAAABB BBCCCC |
user output |
---|
ABACBC BACACB |
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 |
---|
ABACA BABAC |
Test 23
Verdict: ACCEPTED
input |
---|
BABACAABAB |
correct output |
---|
AAAAA BBBBC |
user output |
---|
ABABA BABAC |
Test 24
Verdict: ACCEPTED
input |
---|
CCAABBABCBAA |
correct output |
---|
AAAAAB BBBCCC |
user output |
---|
ABACAC BABACB |
Test 25
Verdict: ACCEPTED
input |
---|
AABBAAABBB |
correct output |
---|
AAAAA BBBBB |
user output |
---|
ABABA BABAB |
Test 26
Verdict: ACCEPTED
input |
---|
BABAACACBBAB |
correct output |
---|
AAAAAB BBBBCC |
user output |
---|
ABABAC BABACB |
Test 27
Verdict: ACCEPTED
input |
---|
AABBBCCABCABAC |
correct output |
---|
AAAAABB BBBCCCC |
user output |
---|
ABACACB BABACBC |
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 |
---|
ABACAC BABACA |
Test 34
Verdict: ACCEPTED
input |
---|
BBBAAAABAA |
correct output |
---|
-1 |
user output |
---|
-1 |
Test 35
Verdict: ACCEPTED
input |
---|
ABBABBAAACCA |
correct output |
---|
AAAAAA BBBBCC |
user output |
---|
ABABAC BABACA |
Test 36
Verdict: ACCEPTED
input |
---|
BCACABBACACABA |
correct output |
---|
AAAAAAB BBBCCCC |
user output |
---|
ABACACB BABACAC |
Test 37
Verdict: ACCEPTED
input |
---|
BAABCBAAAABB |
correct output |
---|
AAAAAA BBBBBC |
user output |
---|
ABABAC BABABA |
Test 38
Verdict: ACCEPTED
input |
---|
ABBAACCABBCABA |
correct output |
---|
AAAAAAB BBBBCCC |
user output |
---|
ABABACB BABACAC |
Test 39
Verdict: ACCEPTED
input |
---|
ABCACCBABBAACABC |
correct output |
---|
AAAAAABB BBBCCCCC |
user output |
---|
ABACACBC BABACACB |
Test 40
Verdict: ACCEPTED
input |
---|
ABBBAAABBABA |
correct output |
---|
AAAAAA BBBBBB |
user output |
---|
ABABAB BABABA |
Test 41
Verdict: ACCEPTED
input |
---|
AAACAABBCABBBB |
correct output |
---|
AAAAAAB BBBBBCC |
user output |
---|
ABABACB BABABAC |
Test 42
Verdict: ACCEPTED
input |
---|
BCBBBCAABABCCAAA |
correct output |
---|
AAAAAABB BBBBCCCC |
user output |
---|
ABABACBC BABACACB |
Test 43
Verdict: ACCEPTED
input |
---|
BBCBAABACCCBAACACB |
correct output |
---|
AAAAAABBB BBBCCCCCC |
user output |
---|
ABACACBCB BABACACBC |
Test 44
Verdict: ACCEPTED
input |
---|
BBABBABABAABAAABBAAABBBBBBAABB... |
correct output |
---|
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA... |
user output |
---|
ABABABABABABABABABABABABABABAB... |
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 |
---|
AMAMAMAMAMAMAMAMAMAMAMAMAMAMAM... |