Task: | Median string |
Sender: | Ace of Spades |
Submission time: | 2017-05-27 15:04:51 +0300 |
Language: | C++ |
Status: | READY |
Result: | RUNTIME ERROR |
test | verdict | time | |
---|---|---|---|
#1 | ACCEPTED | 0.05 s | details |
#2 | RUNTIME ERROR | 0.18 s | details |
#3 | ACCEPTED | 0.07 s | details |
#4 | ACCEPTED | 0.05 s | details |
#5 | RUNTIME ERROR | 0.28 s | details |
#6 | ACCEPTED | 0.06 s | details |
#7 | ACCEPTED | 0.03 s | details |
#8 | ACCEPTED | 0.07 s | details |
#9 | ACCEPTED | 0.04 s | details |
#10 | ACCEPTED | 0.04 s | details |
#11 | ACCEPTED | 0.05 s | details |
#12 | ACCEPTED | 0.06 s | details |
#13 | ACCEPTED | 0.04 s | details |
#14 | ACCEPTED | 0.05 s | details |
#15 | ACCEPTED | 0.05 s | details |
#16 | ACCEPTED | 0.06 s | details |
#17 | ACCEPTED | 0.06 s | details |
#18 | ACCEPTED | 0.05 s | details |
#19 | ACCEPTED | 0.06 s | details |
#20 | ACCEPTED | 0.05 s | details |
#21 | ACCEPTED | 0.07 s | details |
#22 | ACCEPTED | 0.06 s | details |
#23 | ACCEPTED | 0.06 s | details |
#24 | ACCEPTED | 0.03 s | details |
#25 | ACCEPTED | 0.06 s | details |
#26 | ACCEPTED | 0.09 s | details |
#27 | ACCEPTED | 0.09 s | details |
#28 | ACCEPTED | 0.13 s | details |
#29 | ACCEPTED | 0.09 s | details |
#30 | ACCEPTED | 0.09 s | details |
#31 | ACCEPTED | 0.10 s | details |
#32 | ACCEPTED | 0.11 s | details |
#33 | ACCEPTED | 0.09 s | details |
#34 | ACCEPTED | 0.10 s | details |
#35 | ACCEPTED | 0.09 s | details |
#36 | RUNTIME ERROR | 0.32 s | details |
#37 | ACCEPTED | 0.09 s | details |
#38 | ACCEPTED | 0.11 s | details |
#39 | RUNTIME ERROR | 0.24 s | details |
#40 | ACCEPTED | 0.09 s | details |
#41 | ACCEPTED | 0.08 s | details |
#42 | ACCEPTED | 0.12 s | details |
#43 | ACCEPTED | 0.09 s | details |
#44 | ACCEPTED | 0.08 s | details |
#45 | ACCEPTED | 0.09 s | details |
Compiler report
input/code.cpp: In function 'int main()': input/code.cpp:49:21: warning: array subscript has type 'char' [-Wchar-subscripts] if(a1) t[a[i]]++; ^ input/code.cpp:50:21: warning: array subscript has type 'char' [-Wchar-subscripts] if(b1) t[b[j]]++; ^ input/code.cpp:51:21: warning: array subscript has type 'char' [-Wchar-subscripts] if(c1) t[c[k]]++; ^ input/code.cpp:53:23: warning: array subscript has type 'char' [-Wchar-subscripts] if(a1 && t[a[i]] > 1) q = a[i]; ^ input/code.cpp:54:23: warning: array subscript has type 'char' [-Wchar-subscripts] if(b1 && t[b[j]] > 1) q = b[j]; ^ input/code.cpp:55:23: warning: array subscript has type 'char' [-Wchar-subscripts] if(c1 && t[c[k]] > 1) q = c[k]; ^ input/code.cpp:70:21: warning: array subscript has type 'char' [-Wchar-subscripts] if(a1) t[a[i]]--;...
Code
#include <bits/stdc++.h>using namespace std;string dp2[51][51][51];int dp[51][51][51];int main() {for(int i = 0; i < 51; ++i) {for(int j = 0; j < 51; ++j) {for(int k = 0; k < 51; ++k) {dp[i][j][k] = 1e9;}}}string a,b,c;cin>>a>>b>>c;int an, bn, cn;an = a.size();bn = b.size();cn = c.size();int t[200] = {0};dp[0][0][0] = 0;for(int i = 0; i <= an; ++i) {for(int j = 0; j <= bn; ++j) {for(int k = 0; k <= cn; ++k) {if(i < an) {if(dp[i+1][j][k] > dp[i][j][k]+1) {dp[i+1][j][k] = dp[i][j][k]+1;dp2[i+1][j][k] = dp2[i][j][k];}}if(j < bn) {if(dp[i][j+1][k] > dp[i][j][k]+1) {dp[i][j+1][k] = dp[i][j][k]+1;dp2[i][j+1][k] = dp2[i][j][k];}}if(k < cn) {if(dp[i][j][k+1] > dp[i][j][k]+1) {dp[i][j][k+1] = dp[i][j][k]+1;dp2[i][j][k+1] = dp2[i][j][k];}}for(int a1 = 0; a1 < 2; ++a1) {for(int b1 = 0; b1 < 2; ++b1) {for(int c1 = 0; c1 < 2; ++c1) {int cost = 0;if(a1 == 0) ++cost;if(b1 == 0) ++cost;if(c1 == 0) ++cost;if(a1) t[a[i]]++;if(b1) t[b[j]]++;if(c1) t[c[k]]++;char q = 0;if(a1 && t[a[i]] > 1) q = a[i];if(b1 && t[b[j]] > 1) q = b[j];if(c1 && t[c[k]] > 1) q = c[k];if(q == 0) {if(a1) q = a[i];if(b1) q = b[j];if(c1) q = c[k];}if(a1) cost += (a[i] != q);if(b1) cost += (b[j] != q);if(c1) cost += (c[k] != q);if(dp[i+a1][j+b1][k+c1] > dp[i][j][k] + cost) {dp[i+a1][j+b1][k+c1] = dp[i][j][k] + cost;dp2[i+a1][j+b1][k+c1] = dp2[i][j][k];dp2[i+a1][j+b1][k+c1].push_back(q);}if(a1) t[a[i]]--;if(b1) t[b[j]]--;if(c1) t[c[k]]--;}}}}}}cout<<dp2[an][bn][cn]<<endl;}
Test details
Test 1
Verdict: ACCEPTED
input |
---|
A A A |
correct output |
---|
A |
user output |
---|
A |
Test 2
Verdict: RUNTIME ERROR
input |
---|
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA... |
correct output |
---|
A |
user output |
---|
(empty) |
Test 3
Verdict: ACCEPTED
input |
---|
A AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA... |
correct output |
---|
A |
user output |
---|
A |
Test 4
Verdict: ACCEPTED
input |
---|
A A AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA... |
correct output |
---|
A |
user output |
---|
A |
Test 5
Verdict: RUNTIME ERROR
input |
---|
EEBAKAUUFWHXAHYEANNASFUDNDZXXL... |
correct output |
---|
EGBAKBBMFTHFJHEAKDASLFHBNZGXVM... |
user output |
---|
(empty) |
Test 6
Verdict: ACCEPTED
input |
---|
BABAAAAB BBAAAAAAB BBBABABB |
correct output |
---|
BBABAAAAB |
user output |
---|
BABAAAAB |
Test 7
Verdict: ACCEPTED
input |
---|
AAAAA AAABAAA BBAAAA |
correct output |
---|
AAAAAA |
user output |
---|
BAAAAA |
Test 8
Verdict: ACCEPTED
input |
---|
AABAABB ABAAAB BBABAABA |
correct output |
---|
ABABAABA |
user output |
---|
BABAABB |
Test 9
Verdict: ACCEPTED
input |
---|
BAABAB BBAAABAAAA ABAAABBB |
correct output |
---|
BBAAABAB |
user output |
---|
ABAAABAB |
Test 10
Verdict: ACCEPTED
input |
---|
BABAB AABABBBA BABABBB |
correct output |
---|
BABABBB |
user output |
---|
BABABBB |
Test 11
Verdict: ACCEPTED
input |
---|
AAABBBABBB BABBABABB ABBBB |
correct output |
---|
AABBBABB |
user output |
---|
BABBBABB |
Test 12
Verdict: ACCEPTED
input |
---|
AABAAABBAA BABAB BBBAA |
correct output |
---|
BABBAA |
user output |
---|
BBBAA |
Test 13
Verdict: ACCEPTED
input |
---|
BBBBBBBBA AABABAABA ABBBAAA |
correct output |
---|
ABBBBAABA |
user output |
---|
AABBBAABA |
Test 14
Verdict: ACCEPTED
input |
---|
BABBBABAA AABBBBABB AABBBAB |
correct output |
---|
AABBBABA |
user output |
---|
AABBBABB |
Test 15
Verdict: ACCEPTED
input |
---|
ABBBBBBB ABBABABBA BBBBABBBA |
correct output |
---|
ABBBBABBBA |
user output |
---|
ABBBBBBA |
Test 16
Verdict: ACCEPTED
input |
---|
BBABABAB BBBBBA AABAAA |
correct output |
---|
BBABABA |
user output |
---|
BABABA |
Test 17
Verdict: ACCEPTED
input |
---|
AAABAAAA ABABAB BBBBBBB |
correct output |
---|
ABABABA |
user output |
---|
BABABAB |
Test 18
Verdict: ACCEPTED
input |
---|
BBABABA BABAAAABAA BABBB |
correct output |
---|
BABABABA |
user output |
---|
BBABABA |
Test 19
Verdict: ACCEPTED
input |
---|
AABBABB BBBBAABBBA BAABBAA |
correct output |
---|
BAABBABA |
user output |
---|
BAABBBA |
Test 20
Verdict: ACCEPTED
input |
---|
BBBBBAA AAABAAAA AAABBABB |
correct output |
---|
AAABBAAA |
user output |
---|
AAABBAAA |
Test 21
Verdict: ACCEPTED
input |
---|
AAAABBA ABAABA BBABBBBBA |
correct output |
---|
ABAABBA |
user output |
---|
ABAABBA |
Test 22
Verdict: ACCEPTED
input |
---|
BBBABAB ABBABBBAA ABBBAABABB |
correct output |
---|
ABBBABAB |
user output |
---|
ABBBABAB |
Test 23
Verdict: ACCEPTED
input |
---|
BBAAA BBABAB ABBBBABBB |
correct output |
---|
BBABAB |
user output |
---|
BBABAB |
Test 24
Verdict: ACCEPTED
input |
---|
AABABBBAAB BBBABBBA ABBAAAB |
correct output |
---|
ABBABBBAAB |
user output |
---|
ABBABBAAB |
Test 25
Verdict: ACCEPTED
input |
---|
ABBBBBBBB BAABAABAAA BAAAABAAAB |
correct output |
---|
BAABAABAAAB |
user output |
---|
BAABABBAAB |
Test 26
Verdict: ACCEPTED
input |
---|
BBDDCBBCDBAABAACBAADACABBDDABB... |
correct output |
---|
BADACCBCDBADBAACBAADACBABBCABB... |
user output |
---|
CADACCBCDBADBAACBAADCBABBCABBD... |
Test 27
Verdict: ACCEPTED
input |
---|
ADCDADBDDDCACBCCBCACDCDBCBCDBB... |
correct output |
---|
DCAADADCDACBDBBDABDCCDBCABCBAC... |
user output |
---|
DCAADADCDACBDBBDABCCCDBCBCBACA... |
Test 28
Verdict: ACCEPTED
input |
---|
CBCBABACDDACDCBCBBBADACDCDCBCA... |
correct output |
---|
DCACBABDCABCCACBCCBCBADABCDDCC... |
user output |
---|
DCACBCBDCBCACBCCBCBADBCDDCCABA... |
Test 29
Verdict: ACCEPTED
input |
---|
CCBADBAACDDCBAABCADBDBDCCBCCDC... |
correct output |
---|
CABCBBABBDBAAACBDDABDAABCABBDB... |
user output |
---|
CABCDBABBDDCAAABDDABBDBADCABCC... |
Test 30
Verdict: ACCEPTED
input |
---|
DCBDBABAADBDCDCDDDCCDACADDCCAC... |
correct output |
---|
DCBABACDDBACDCBDDACAACADDCCACD... |
user output |
---|
DBABACBDDBCCDCBDDACAACADDCCACD... |
Test 31
Verdict: ACCEPTED
input |
---|
BCBACAADABAACACADCADCDAAACDDDD... |
correct output |
---|
BCDCCBADDBBACDCADCDAADACDBDADA... |
user output |
---|
BCDCCBCDDBBBCDCADCDAADACDBDADA... |
Test 32
Verdict: ACCEPTED
input |
---|
ACDCDACCABADADABADDAAACBDCABBB... |
correct output |
---|
ACDADACCABABACABADAABACBDCABBA... |
user output |
---|
ACDADACCABABAAABADBCAACDDCABBD... |
Test 33
Verdict: ACCEPTED
input |
---|
ABCCDCADCDADAADBDDBBABDACBBAAC... |
correct output |
---|
BCDADCDBABDBDDCBDABDACBBAAADCA... |
user output |
---|
BCDADCDDABDBDCBDABDACBBAADDCAB... |
Test 34
Verdict: ACCEPTED
input |
---|
DABDBACDBADABBDDBAACCAADABDBBD... |
correct output |
---|
DABDCBACADBDADCAABDBDBAACDAADA... |
user output |
---|
DCBDCBAACDBDACACBDCDBABACDAADA... |
Test 35
Verdict: ACCEPTED
input |
---|
BCBABDCADCBADCAABCACCBDAABBCBD... |
correct output |
---|
BCBDBDCADBBBBCCABCDADBDAADBCBD... |
user output |
---|
BCBDBCADBBBBCCABCDADBDAADBCBDB... |
Test 36
Verdict: RUNTIME ERROR
input |
---|
TFWRLHNANNYROWCGQJUHNIAHQTQMJF... |
correct output |
---|
TFCRBHJANDNYJOCGQPJAHNIACFJCMJ... |
user output |
---|
(empty) |
Test 37
Verdict: ACCEPTED
input |
---|
HLQGBFZAPEMVFIDMBTZLKOSTCSBKPX... |
correct output |
---|
HKVGBAKAWEACFIBHCMNBTALCLSTSBJ... |
user output |
---|
PKAWBAUFUOFHCMBTYRWTSTJDLQPXNH... |
Test 38
Verdict: ACCEPTED
input |
---|
BURAOHCWCRFABWYQTGIDCIJZGAGOQH... |
correct output |
---|
BUMIHPWFBAAMWREPGDCIJIGGGQHJAJ... |
user output |
---|
VUMIHPWFBAAMWRWXGPCOJSGGGVHJCP... |
Test 39
Verdict: RUNTIME ERROR
input |
---|
JHLXFPNXFCWAXXBNOOKKAAOYCAJQNC... |
correct output |
---|
FHPNDFCWABLINDFGCAAFYCMJNCCHYE... |
user output |
---|
(empty) |
Test 40
Verdict: ACCEPTED
input |
---|
XPRJAEQNVMRJPRONUEBLIRWTWQLPCT... |
correct output |
---|
XRIAEFBHMDICDNJEBLIJDTHQCXRNAA... |
user output |
---|
XRYCEFBHMDICSNJZJUIJETHQCXRNPA... |
Test 41
Verdict: ACCEPTED
input |
---|
LIFBDNCQAUIBFDBQWYQYHHIHTILAGL... |
correct output |
---|
GLGNIKBDNSQAJIUDBJYFIILAGJCEAK... |
user output |
---|
GLGTIKEFNSQHZIUDBJYFIILAGRMRQC... |
Test 42
Verdict: ACCEPTED
input |
---|
XVRPEIHNUVILHOMUZVSDUBCCWFCUPR... |
correct output |
---|
XHJPIADTKEFHOUZSDUYCBAFCAHBGEU... |
user output |
---|
XHWPVTDWXEFHOUZSDUMYLBFHHQBOEI... |
Test 43
Verdict: ACCEPTED
input |
---|
NVXEUOKZUBIPREENTXKZNJCKOJWSZX... |
correct output |
---|
NVEUJFZJNGPJUEVTJHNJCKOAWSFZUA... |
user output |
---|
FNHXHUIVZJNGPAJDLOWRZAWCKYTKRZ... |
Test 44
Verdict: ACCEPTED
input |
---|
TPMZYIOLFNHUYUTQEGXKDUVWIIGPZR... |
correct output |
---|
TEDBKIWELFIHKUYBOANEGDCBJIBBEZ... |
user output |
---|
YEDBUIWLPTXUYWOWTGQKOIEWIFJPUR... |
Test 45
Verdict: ACCEPTED
input |
---|
OPTIBHSPIKWOVIIAJSDRGAHPPSWHGZ... |
correct output |
---|
BHSPICWOJIIENAGODCGAHKGDWHGCAB... |
user output |
---|
GHWQYCWOKILMNAGXDCMMHKIDWHGCAB... |