Task: | Freight trains |
Sender: | aalto2024e_002 |
Submission time: | 2024-09-30 17:30:24 +0300 |
Language: | C++ (C++17) |
Status: | READY |
Result: | ACCEPTED |
test | verdict | time | |
---|---|---|---|
#1 | ACCEPTED | 0.00 s | details |
#2 | ACCEPTED | 0.00 s | details |
#3 | ACCEPTED | 0.00 s | details |
#4 | ACCEPTED | 0.01 s | details |
#5 | ACCEPTED | 0.00 s | details |
#6 | ACCEPTED | 0.00 s | details |
#7 | ACCEPTED | 0.00 s | details |
#8 | ACCEPTED | 0.00 s | details |
#9 | ACCEPTED | 0.00 s | details |
#10 | ACCEPTED | 0.00 s | details |
#11 | ACCEPTED | 0.00 s | details |
#12 | ACCEPTED | 0.00 s | details |
#13 | ACCEPTED | 0.00 s | details |
#14 | ACCEPTED | 0.00 s | details |
#15 | ACCEPTED | 0.00 s | details |
#16 | ACCEPTED | 0.00 s | details |
#17 | ACCEPTED | 0.00 s | details |
#18 | ACCEPTED | 0.00 s | details |
#19 | ACCEPTED | 0.00 s | details |
#20 | ACCEPTED | 0.00 s | details |
#21 | ACCEPTED | 0.00 s | details |
#22 | ACCEPTED | 0.00 s | details |
#23 | ACCEPTED | 0.00 s | details |
#24 | ACCEPTED | 0.00 s | details |
#25 | ACCEPTED | 0.00 s | details |
#26 | ACCEPTED | 0.00 s | details |
#27 | ACCEPTED | 0.00 s | details |
#28 | ACCEPTED | 0.00 s | details |
#29 | ACCEPTED | 0.00 s | details |
#30 | ACCEPTED | 0.00 s | details |
#31 | ACCEPTED | 0.00 s | details |
#32 | ACCEPTED | 0.00 s | details |
#33 | ACCEPTED | 0.00 s | details |
#34 | ACCEPTED | 0.00 s | details |
#35 | ACCEPTED | 0.00 s | details |
#36 | ACCEPTED | 0.00 s | details |
#37 | ACCEPTED | 0.00 s | details |
#38 | ACCEPTED | 0.00 s | details |
#39 | ACCEPTED | 0.00 s | details |
#40 | ACCEPTED | 0.00 s | details |
#41 | ACCEPTED | 0.00 s | details |
#42 | ACCEPTED | 0.00 s | details |
#43 | ACCEPTED | 0.00 s | details |
#44 | ACCEPTED | 0.00 s | details |
#45 | ACCEPTED | 0.00 s | details |
#46 | ACCEPTED | 0.00 s | details |
#47 | ACCEPTED | 0.00 s | details |
#48 | ACCEPTED | 0.00 s | details |
#49 | ACCEPTED | 0.00 s | details |
#50 | ACCEPTED | 0.00 s | details |
#51 | ACCEPTED | 0.00 s | details |
#52 | ACCEPTED | 0.00 s | details |
#53 | ACCEPTED | 0.00 s | details |
#54 | ACCEPTED | 0.00 s | details |
#55 | ACCEPTED | 0.00 s | details |
#56 | ACCEPTED | 0.00 s | details |
#57 | ACCEPTED | 0.00 s | details |
#58 | ACCEPTED | 0.00 s | details |
#59 | ACCEPTED | 0.00 s | details |
#60 | ACCEPTED | 0.00 s | details |
#61 | ACCEPTED | 0.00 s | details |
#62 | ACCEPTED | 0.04 s | details |
#63 | ACCEPTED | 0.04 s | details |
#64 | ACCEPTED | 0.04 s | details |
#65 | ACCEPTED | 0.04 s | details |
#66 | ACCEPTED | 0.04 s | details |
#67 | ACCEPTED | 0.04 s | details |
#68 | ACCEPTED | 0.04 s | details |
#69 | ACCEPTED | 0.04 s | details |
#70 | ACCEPTED | 0.04 s | details |
#71 | ACCEPTED | 0.04 s | details |
Compiler report
input/code.cpp: In function 'int comp(std::string&, std::string&)': input/code.cpp:40:21: warning: comparison of integer expressions of different signedness: 'int' and 'size_t' {aka 'long unsigned int'} [-Wsign-compare] 40 | for (int i = 0; i < length_a + length_b; i++) { | ~~^~~~~~~~~~~~~~~~~~~~~ input/code.cpp:41:22: warning: comparison of integer expressions of different signedness: 'int' and 'size_t' {aka 'long unsigned int'} [-Wsign-compare] 41 | char char_a = (i < length_a) ? a[i] : b[i - length_a]; | ~~^~~~~~~~~~ input/code.cpp:42:22: warning: comparison of integer expressions of different signedness: 'int' and 'size_t' {aka 'long unsigned int'} [-Wsign-compare] 42 | char char_b = (i < length_b) ? b[i] : a[i - length_b]; | ~~^~~~~~~~~~
Code
#include <bits/stdc++.h> using namespace std; #define PRINT_ARR(arr, n) \ do { \ for (int i = 0; i < n; i++) { \ cout << arr[i] << " "; \ } \ cout << "\n"; \ } while (0) typedef long long ll; // int cmp(string a, string b, string c) { // int i =0; // if (a.size() < 2 && b.size() < 2) { // return // } // while (i < a.size() && i < b.size() && a[i] == b[i]) // i++; // if (a[i-1] != b[i-1]) // // } int cmp(string &a, string &b) { size_t la = a.length(); size_t lb = b.length(); size_t i = 0; size_t ll = min(la, lb); while (i < ll && a[i] == b[i]) i++; if (i < ll) { return a[i] < b[i]; } return la > lb; } int comp(string &a, string &b) { size_t length_a = a.length(); size_t length_b = b.length(); for (int i = 0; i < length_a + length_b; i++) { char char_a = (i < length_a) ? a[i] : b[i - length_a]; char char_b = (i < length_b) ? b[i] : a[i - length_b]; if (char_a < char_b) { return true; } else if (char_a > char_b) { return false; } } return false; } int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int n; cin >> n; vector<string> arr(n); string t; if (n == 1) { cin >> t; cout << t << endl; return 0; } for (int i = 0; i < n; i++) { cin >> arr[i]; } sort(arr.begin(), arr.end(), comp); // PRINT_ARR(arr, n); // int l = 0, r = 1; // while (l < n && r < n) { // if (comp(arr[l], arr[r])) { // cout << arr[l]; // l = max(l, r) + 1; // } else { // cout << arr[r]; // r = max(l, r) + 1; // } // } // cout << arr[min(l, r)] << endl; for (auto s : arr) { cout << s; } cout << endl; }
Test details
Test 1
Verdict: ACCEPTED
input |
---|
1 gl |
correct output |
---|
gl |
user output |
---|
gl |
Test 2
Verdict: ACCEPTED
input |
---|
2 adedf ff |
correct output |
---|
adedfff |
user output |
---|
adedfff |
Test 3
Verdict: ACCEPTED
input |
---|
2 jb lj |
correct output |
---|
jblj |
user output |
---|
jblj |
Test 4
Verdict: ACCEPTED
input |
---|
2 qlipb sr |
correct output |
---|
qlipbsr |
user output |
---|
qlipbsr |
Test 5
Verdict: ACCEPTED
input |
---|
3 f llk onfj |
correct output |
---|
fllkonfj |
user output |
---|
fllkonfj |
Test 6
Verdict: ACCEPTED
input |
---|
3 jaeo mob nk |
correct output |
---|
jaeomobnk |
user output |
---|
jaeomobnk |
Test 7
Verdict: ACCEPTED
input |
---|
3 nemlo psqhy sg |
correct output |
---|
nemlopsqhysg |
user output |
---|
nemlopsqhysg |
Test 8
Verdict: ACCEPTED
input |
---|
4 dia eh fbcae gf |
correct output |
---|
diaehfbcaegf |
user output |
---|
diaehfbcaegf |
Test 9
Verdict: ACCEPTED
input |
---|
4 c cbfaa egbg fc |
correct output |
---|
cbfaacegbgfc |
user output |
---|
cbfaacegbgfc |
Test 10
Verdict: ACCEPTED
input |
---|
4 cbc cdd ceed dbeea |
correct output |
---|
cbccddceeddbeea |
user output |
---|
cbccddceeddbeea |
Test 11
Verdict: ACCEPTED
input |
---|
4 bfec bgbaf fcg fdbbg |
correct output |
---|
bfecbgbaffcgfdbbg |
user output |
---|
bfecbgbaffcgfdbbg |
Test 12
Verdict: ACCEPTED
input |
---|
5 aoefh ge imgjj kmj ... |
correct output |
---|
aoefhgeimgjjkmjmhhi |
user output |
---|
aoefhgeimgjjkmjmhhi |
Test 13
Verdict: ACCEPTED
input |
---|
5 bcbec ei fdigc ilabd ... |
correct output |
---|
bcbeceifdigcilabdlg |
user output |
---|
bcbeceifdigcilabdlg |
Test 14
Verdict: ACCEPTED
input |
---|
5 a d db glfff ... |
correct output |
---|
adbdglfffih |
user output |
---|
adbdglfffih |
Test 15
Verdict: ACCEPTED
input |
---|
5 ab d ebhin k ... |
correct output |
---|
abdebhinknab |
user output |
---|
abdebhinknab |
Test 16
Verdict: ACCEPTED
input |
---|
5 fasgx o oezws qua ... |
correct output |
---|
fasgxoezwsoquaspfd |
user output |
---|
fasgxoezwsoquaspfd |
Test 17
Verdict: ACCEPTED
input |
---|
5 bcggd dcg e fc ... |
correct output |
---|
bcggddcgefcg |
user output |
---|
bcggddcgefcg |
Test 18
Verdict: ACCEPTED
input |
---|
5 cmo cx hftbb mil ... |
correct output |
---|
cmocxhftbbmiltksr |
user output |
---|
cmocxhftbbmiltksr |
Test 19
Verdict: ACCEPTED
input |
---|
5 ab ababa b ca ... |
correct output |
---|
ababaabbcaccb |
user output |
---|
ababaabbcaccb |
Test 20
Verdict: ACCEPTED
input |
---|
5 o rjj sfj ti ... |
correct output |
---|
orjjsfjtiw |
user output |
---|
orjjsfjtiw |
Test 21
Verdict: ACCEPTED
input |
---|
5 a aa aaa abbab ... |
correct output |
---|
aaaaaaabbabba |
user output |
---|
aaaaaaabbabba |
Test 22
Verdict: ACCEPTED
input |
---|
10 aoefh f ge hlmgh ... |
correct output |
---|
aoefhfgehlmghimgjjjkmjmhhinmol... |
user output |
---|
aoefhfgehlmghimgjjjkmjmhhinmol... |
Test 23
Verdict: ACCEPTED
input |
---|
10 bcbec cjjil dbigk ei ... |
correct output |
---|
bcbeccjjildbigkeifdigcgfbikfil... |
user output |
---|
bcbeccjjildbigkeifdigcgfbikfil... |
Test 24
Verdict: ACCEPTED
input |
---|
10 a cij d db ... |
correct output |
---|
acijdbddhhekcgibfgglfffihkg |
user output |
---|
acijdbddhhekcgibfgglfffihkg |
Test 25
Verdict: ACCEPTED
input |
---|
10 ab d ebhin fk ... |
correct output |
---|
abdebhinfkgjdinaiodgkacknab |
user output |
---|
abdebhinfkgjdinaiodgkacknab |
Test 26
Verdict: ACCEPTED
input |
---|
10 buywl fasgx gb jzpek ... |
correct output |
---|
buywlfasgxgbjzpekoezwsoquaspfd... |
user output |
---|
buywlfasgxgbjzpekoezwsoquaspfd... |
Test 27
Verdict: ACCEPTED
input |
---|
10 acg bcggd dcg dede ... |
correct output |
---|
acgbcggddcgdedeefcfdbbfgabbg |
user output |
---|
acgbcggddcgdedeefcfdbbfgabbg |
Test 28
Verdict: ACCEPTED
input |
---|
10 cmo cx dpr dtir ... |
correct output |
---|
cmocxdprdtirhftbbmfmiltksrttkb... |
user output |
---|
cmocxdprdtirhftbbmfmiltksrttkb... |
Test 29
Verdict: ACCEPTED
input |
---|
10 ab ababa abbc b ... |
correct output |
---|
ababaababbcbbbcaccbcccccc |
user output |
---|
ababaababbcbbbcaccbcccccc |
Test 30
Verdict: ACCEPTED
input |
---|
10 dmq gl j jqso ... |
correct output |
---|
dmqgljjqsoorjjsfjtiulvw |
user output |
---|
dmqgljjqsoorjjsfjtiulvw |
Test 31
Verdict: ACCEPTED
input |
---|
10 a aa aaa abbab ... |
correct output |
---|
aaaaaaabbabbabbabbabbbbbabbbbb |
user output |
---|
aaaaaaabbabbabbabbabbbbbabbbbb |
Test 32
Verdict: ACCEPTED
input |
---|
100 aa acmfac afmolcn alllbndbli ... |
correct output |
---|
aaacmfacafmolcnalllbndbliamdal... |
user output |
---|
aaacmfacafmolcnalllbndbliamdal... Truncated |
Test 33
Verdict: ACCEPTED
input |
---|
100 a acjgj ae aegdb ... |
correct output |
---|
aacjgjaeaegdbafcbahledfchagaja... |
user output |
---|
aacjgjaeaegdbafcbahledfchagaja... Truncated |
Test 34
Verdict: ACCEPTED
input |
---|
100 a aah abaeeaifc abajl ... |
correct output |
---|
aaahabaeeaifcabajlaehaejcdegka... |
user output |
---|
aaahabaeeaifcabajlaehaejcdegka... Truncated |
Test 35
Verdict: ACCEPTED
input |
---|
100 a aa abg abndfmmmk ... |
correct output |
---|
aaaabgabndfmmmkacggjdeacogeada... |
user output |
---|
aaaabgabndfmmmkacggjdeacogeada... Truncated |
Test 36
Verdict: ACCEPTED
input |
---|
100 afn aic ajrkgzldb amcyqyh ... |
correct output |
---|
afnaicajrkgzldbamcyqyhandanxhj... |
user output |
---|
afnaicajrkgzldbamcyqyhandanxhj... Truncated |
Test 37
Verdict: ACCEPTED
input |
---|
100 aacdeffdd abaacbae abfbbff ac ... |
correct output |
---|
aacdeffddabaacbaeabfbbffacacbg... |
user output |
---|
aacdeffddabaacbaeabfbbffacacbg... Truncated |
Test 38
Verdict: ACCEPTED
input |
---|
100 abnfxhutgk ajkdoqmdqp asxeblm badpwpsqhn ... |
correct output |
---|
abnfxhutgkajkdoqmdqpasxeblmbad... |
user output |
---|
abnfxhutgkajkdoqmdqpasxeblmbad... Truncated |
Test 39
Verdict: ACCEPTED
input |
---|
100 a aa aaaaacaca aaaabcabc ... |
correct output |
---|
aaaaaaaacacaaaaabcabcaaabaaaab... |
user output |
---|
aaaaaaaacacaaaaabcabcaaabaaaab... Truncated |
Test 40
Verdict: ACCEPTED
input |
---|
100 a aiesfhkro aivvkdc ajrtj ... |
correct output |
---|
aaiesfhkroaivvkdcajrtjaqfnivlb... |
user output |
---|
aaiesfhkroaivvkdcajrtjaqfnivlb... Truncated |
Test 41
Verdict: ACCEPTED
input |
---|
100 a aa aaaa aaaaa ... |
correct output |
---|
aaaaaaaaaaaaaaaaaaaaaaaaaaabab... |
user output |
---|
aaaaaaaaaaaaaaaaaaaaaaaaaaabab... Truncated |
Test 42
Verdict: ACCEPTED
input |
---|
200 a aa abbhjifdb acmfac ... |
correct output |
---|
aaaabbhjifdbacmfacadiadnhkaehh... |
user output |
---|
aaaabbhjifdbacmfacadiadnhkaehh... Truncated |
Test 43
Verdict: ACCEPTED
input |
---|
200 a aa abihiahg acjgj ... |
correct output |
---|
aaaabihiahgacjgjadaeaegdbafcba... |
user output |
---|
aaaabihiahgacjgjadaeaegdbafcba... Truncated |
Test 44
Verdict: ACCEPTED
input |
---|
200 a aah abaeeaifc abajl ... |
correct output |
---|
aaahabaeeaifcabajlaehaejcdegka... |
user output |
---|
aaahabaeeaifcabajlaehaejcdegka... Truncated |
Test 45
Verdict: ACCEPTED
input |
---|
200 a aa aan abg ... |
correct output |
---|
aaaaanabgabndfmmmkacggjdeacoge... |
user output |
---|
aaaaanabgabndfmmmkacggjdeacoge... Truncated |
Test 46
Verdict: ACCEPTED
input |
---|
200 ad aegewtfc afn aic ... |
correct output |
---|
adaegewtfcafnaicajrkgzldbamcyq... |
user output |
---|
adaegewtfcafnaicajrkgzldbamcyq... Truncated |
Test 47
Verdict: ACCEPTED
input |
---|
200 a aa aacdeffdd aaeceaeb ... |
correct output |
---|
aaaaacdeffddaaeceaebabaacbaeab... |
user output |
---|
aaaaacdeffddaaeceaebabaacbaeab... Truncated |
Test 48
Verdict: ACCEPTED
input |
---|
200 abnfxhutgk aghv ajkdoqmdqp ajpvvalnu ... |
correct output |
---|
abnfxhutgkaghvajkdoqmdqpajpvva... |
user output |
---|
abnfxhutgkaghvajkdoqmdqpajpvva... Truncated |
Test 49
Verdict: ACCEPTED
input |
---|
200 a aa aaaaacaca aaaabcabc ... |
correct output |
---|
aaaaaaaacacaaaaabcabcaaaacbcaa... |
user output |
---|
aaaaaaaacacaaaaabcabcaaaacbcaa... Truncated |
Test 50
Verdict: ACCEPTED
input |
---|
200 a abam aiesfhkro aivvkdc ... |
correct output |
---|
aabamaiesfhkroaivvkdcajrtjakam... |
user output |
---|
aabamaiesfhkroaivvkdcajrtjakam... Truncated |
Test 51
Verdict: ACCEPTED
input |
---|
200 a aaicd acbjfaj achddjj ... |
correct output |
---|
aaaicdacbjfajachddjjacifadaecf... |
user output |
---|
aaaicdacbjfajachddjjacifadaecf... Truncated |
Test 52
Verdict: ACCEPTED
input |
---|
1000 a aa aaccbkcd aaj ... |
correct output |
---|
aaaaaccbkcdaajaanabaabanikjabb... |
user output |
---|
aaaaaccbkcdaajaanabaabanikjabb... Truncated |
Test 53
Verdict: ACCEPTED
input |
---|
1000 a aa aabecajcf aabg ... |
correct output |
---|
aaaaabecajcfaabgaabjllgdlkaadg... |
user output |
---|
aaaaabecajcfaabgaabjllgdlkaadg... Truncated |
Test 54
Verdict: ACCEPTED
input |
---|
1000 a aa aablaga aah ... |
correct output |
---|
aaaaablagaaahaajaaklkjjababaee... |
user output |
---|
aaaaablagaaahaajaaklkjjababaee... Truncated |
Test 55
Verdict: ACCEPTED
input |
---|
1000 a aa aagjd aajdlmacjn ... |
correct output |
---|
aaaaagjdaajdlmacjnaakjdngdfaal... |
user output |
---|
aaaaagjdaajdlmacjnaakjdngdfaal... Truncated |
Test 56
Verdict: ACCEPTED
input |
---|
1000 a aalguz abcce abggxup ... |
correct output |
---|
aaalguzabcceabggxupabujabxldxy... |
user output |
---|
aaalguzabcceabggxupabujabxldxy... Truncated |
Test 57
Verdict: ACCEPTED
input |
---|
1000 a aa aaabaaaaf aaaeb ... |
correct output |
---|
aaaaaabaaaafaaaebaabeadaabfffd... |
user output |
---|
aaaaaabaaaafaaaebaabeadaabfffd... Truncated |
Test 58
Verdict: ACCEPTED
input |
---|
1000 a aamuthxggq abnfxhutgk adaumgqm ... |
correct output |
---|
aaamuthxggqabnfxhutgkadaumgqma... |
user output |
---|
aaamuthxggqabnfxhutgkadaumgqma... Truncated |
Test 59
Verdict: ACCEPTED
input |
---|
1000 a aa aaa aaaa ... |
correct output |
---|
aaaaaaaaaaaaaaaaaaaaaaaaaaabaa... |
user output |
---|
aaaaaaaaaaaaaaaaaaaaaaaaaaabaa... Truncated |
Test 60
Verdict: ACCEPTED
input |
---|
1000 a aanmhqqnpc ab abam ... |
correct output |
---|
aaanmhqqnpcababamabginwqvvacba... |
user output |
---|
aaanmhqqnpcababamabginwqvvacba... Truncated |
Test 61
Verdict: ACCEPTED
input |
---|
1000 a aa aaaca aae ... |
correct output |
---|
aaaaaacaaaeaaekcaagjeahdaahhdf... |
user output |
---|
aaaaaacaaaeaaekcaagjeahdaahhdf... Truncated |
Test 62
Verdict: ACCEPTED
input |
---|
100000 a aa aaa aaaagle ... |
correct output |
---|
aaaaaaaaaagleaaabaaabiaaaaccgh... |
user output |
---|
aaaaaaaaaagleaaabaaabiaaaaccgh... Truncated |
Test 63
Verdict: ACCEPTED
input |
---|
100000 a aa aaa aaaagf ... |
correct output |
---|
aaaaaaaaaagfaaaaihlblgaaaalkll... |
user output |
---|
aaaaaaaaaagfaaaaihlblgaaaalkll... Truncated |
Test 64
Verdict: ACCEPTED
input |
---|
100000 a aa aaa aaaa ... |
correct output |
---|
aaaaaaaaaaaaaabkaaaaelbjbaaaaf... |
user output |
---|
aaaaaaaaaaaaaabkaaaaelbjbaaaaf... Truncated |
Test 65
Verdict: ACCEPTED
input |
---|
100000 a aa aaa aaaa ... |
correct output |
---|
aaaaaaaaaaaaaahleaaaajaaabaaab... |
user output |
---|
aaaaaaaaaaaaaahleaaaajaaabaaab... Truncated |
Test 66
Verdict: ACCEPTED
input |
---|
100000 a aa aaa aaacxrqz ... |
correct output |
---|
aaaaaaaaacxrqzaaahaaaahaaaplto... |
user output |
---|
aaaaaaaaacxrqzaaahaaaahaaaplto... Truncated |
Test 67
Verdict: ACCEPTED
input |
---|
100000 a aa aaa aaaa ... |
correct output |
---|
aaaaaaaaaaaaaaaaaaaaaadbaaaaaa... |
user output |
---|
aaaaaaaaaaaaaaaaaaaaaadbaaaaaa... Truncated |
Test 68
Verdict: ACCEPTED
input |
---|
100000 a aa aaa aaail ... |
correct output |
---|
aaaaaaaaailaaaitehaeaaaitxaaam... |
user output |
---|
aaaaaaaaailaaaitehaeaaaitxaaam... Truncated |
Test 69
Verdict: ACCEPTED
input |
---|
100000 a aa aaa aaaa ... |
correct output |
---|
aaaaaaaaaaaaaaabghaaaabcaffaaa... |
user output |
---|
aaaaaaaaaaaaaaabghaaaabcaffaaa... Truncated |
Test 70
Verdict: ACCEPTED
input |
---|
100000 a aa aaa aaaaggo ... |
correct output |
---|
aaaaaaaaaaggoaaacwpgjkvaaaftbl... |
user output |
---|
aaaaaaaaaaggoaaacwpgjkvaaaftbl... Truncated |
Test 71
Verdict: ACCEPTED
input |
---|
100000 a aa aaa aaaa ... |
correct output |
---|
aaaaaaaaaaaaaabaaaagkaaabaaabb... |
user output |
---|
aaaaaaaaaaaaaabaaaagkaaabaaabb... Truncated |