CSES - Aalto Competitive Programming 2024 - wk5 - Mon - Results
Submission details
Task:Freight trains
Sender:aalto2024e_005
Submission time:2024-09-30 16:49:25 +0300
Language:C++ (C++20)
Status:READY
Result:
Test results
testverdicttime
#1ACCEPTED0.00 sdetails
#2ACCEPTED0.00 sdetails
#3ACCEPTED0.00 sdetails
#4ACCEPTED0.00 sdetails
#50.00 sdetails
#6ACCEPTED0.00 sdetails
#7ACCEPTED0.00 sdetails
#80.00 sdetails
#90.00 sdetails
#100.00 sdetails
#110.00 sdetails
#120.00 sdetails
#130.00 sdetails
#140.00 sdetails
#150.00 sdetails
#160.01 sdetails
#170.00 sdetails
#180.00 sdetails
#190.00 sdetails
#200.00 sdetails
#210.00 sdetails
#220.00 sdetails
#230.00 sdetails
#240.00 sdetails
#250.00 sdetails
#260.00 sdetails
#270.00 sdetails
#280.00 sdetails
#290.00 sdetails
#300.00 sdetails
#310.00 sdetails
#320.00 sdetails
#330.00 sdetails
#340.00 sdetails
#350.00 sdetails
#360.00 sdetails
#370.00 sdetails
#380.00 sdetails
#390.00 sdetails
#400.00 sdetails
#410.00 sdetails
#420.00 sdetails
#430.00 sdetails
#440.01 sdetails
#450.00 sdetails
#460.00 sdetails
#470.00 sdetails
#480.00 sdetails
#490.00 sdetails
#500.00 sdetails
#510.00 sdetails
#520.01 sdetails
#530.01 sdetails
#540.01 sdetails
#550.01 sdetails
#560.01 sdetails
#570.01 sdetails
#580.01 sdetails
#590.01 sdetails
#600.01 sdetails
#610.01 sdetails
#620.40 sdetails
#630.43 sdetails
#640.40 sdetails
#650.41 sdetails
#660.38 sdetails
#670.43 sdetails
#680.43 sdetails
#690.46 sdetails
#700.38 sdetails
#710.41 sdetails

Compiler report

input/code.cpp: In function 'int findSmallerInRight(std::string, int)':
input/code.cpp:17:29: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   17 |     for (int i = low + 1; i < str.size(); ++i)
      |                           ~~^~~~~~~~~~~~

Code

#include <iostream>
#include <algorithm>
#include <string>
#include <vector>   

using namespace std;

int fact(int n) { 
    int res = 1;
    for (int i = 2; i <= n; i++) { res *= i; }
    return res;
}

int findSmallerInRight(string str, int low)
{
    int countRight = 0;
    for (int i = low + 1; i < str.size(); ++i)
        if (str[i] < str[low])
            ++countRight;
    return countRight;
}

int findRank(string str)
{
    int n = str.size();
    int rank = 1;  
    int countRight;

    for (int i = 0; i < n; ++i) {

        countRight = findSmallerInRight(str, i);

        rank += countRight * fact(n - i - 1);
    }

    return rank;
}

bool LexCompare(const string& a, const string& b) {
    return findRank(a) > findRank(b);
}


int main(){
    int n;

    cin >> n;

    vector<string> a(n);

    for(int i=0; i<n ;i++)cin >> a[i];

    sort(a.begin(),a.end(), LexCompare);

    for(int i=0; i<n; i++) cout<<a[i];
    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:

input
3
f
llk
onfj

correct output
fllkonfj

user output
onfjllkf

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:

input
4
dia
eh
fbcae
gf

correct output
diaehfbcaegf

user output
fbcaediagfeh

Test 9

Verdict:

input
4
c
cbfaa
egbg
fc

correct output
cbfaacegbgfc

user output
cbfaaegbgfcc

Test 10

Verdict:

input
4
cbc
cdd
ceed
dbeea

correct output
cbccddceeddbeea

user output
dbeeaceedcbccdd

Test 11

Verdict:

input
4
bfec
bgbaf
fcg
fdbbg

correct output
bfecbgbaffcgfdbbg

user output
fdbbgbgbafbfecfcg

Test 12

Verdict:

input
5
aoefh
ge
imgjj
kmj
...

correct output
aoefhgeimgjjkmjmhhi

user output
imgjjaoefhmhhikmjge

Test 13

Verdict:

input
5
bcbec
ei
fdigc
ilabd
...

correct output
bcbeceifdigcilabdlg

user output
ilabdfdigcbcbeclgei

Test 14

Verdict:

input
5
a
d
db
glfff
...

correct output
adbdglfffih

user output
glfffdbihad

Test 15

Verdict:

input
5
ab
d
ebhin
k
...

correct output
abdebhinknab

user output
ebhinnababdk

Test 16

Verdict:

input
5
fasgx
o
oezws
qua
...

correct output
fasgxoezwsoquaspfd

user output
oezwsfasgxspfdquao

Test 17

Verdict:

input
5
bcggd
dcg
e
fc
...

correct output
bcggddcgefcg

user output
bcggddcgfceg

Test 18

Verdict:

input
5
cmo
cx
hftbb
mil
...

correct output
cmocxhftbbmiltksr

user output
hftbbtksrmilcmocx

Test 19

Verdict:

input
5
ab
ababa
b
ca
...

correct output
ababaabbcaccb

user output
ababaccbcaabb

Test 20

Verdict:

input
5
o
rjj
sfj
ti
...

correct output
orjjsfjtiw

user output
rjjsfjtiow

Test 21

Verdict:

input
5
a
aa
aaa
abbab
...

correct output
aaaaaaabbabba

user output
abbabbaaaaaaa

Test 22

Verdict:

input
10
aoefh
f
ge
hlmgh
...

correct output
aoefhfgehlmghimgjjjkmjmhhinmol...

user output
olcnnimgjjhlmghaoefhmhhikmjgen...

Test 23

Verdict:

input
10
bcbec
cjjil
dbigk
ei
...

correct output
bcbeccjjildbigkeifdigcgfbikfil...

user output
ilabdfdigcdbigkcjjilbcbecgfbkc...

Test 24

Verdict:

input
10
a
cij
d
db
...

correct output
acijdbddhhekcgibfgglfffihkg

user output
glfffgibfgekcdbihkgacijddhh

Test 25

Verdict:

input
10
ab
d
ebhin
fk
...

correct output
abdebhinfkgjdinaiodgkacknab

user output
ebhiniodgkacnabgjdinaabdfkk

Test 26

Verdict:

input
10
buywl
fasgx
gb
jzpek
...

correct output
buywlfasgxgbjzpekoezwsoquaspfd...

user output
jzpekoezwsfasgxspfdyvlabuywlva...

Test 27

Verdict:

input
10
acg
bcggd
dcg
dede
...

correct output
acgbcggddcgdedeefcfdbbfgabbg

user output
fdbbgabbbcggddcgdedefcacgefg

Test 28

Verdict:

input
10
cmo
cx
dpr
dtir
...

correct output
cmocxdprdtirhftbbmfmiltksrttkb...

user output
vtljqttkbqhftbbtksrdtirmilmfcm...

Test 29

Verdict:

input
10
ab
ababa
abbc
b
...

correct output
ababaababbcbbbcaccbcccccc

user output
ababaccbcaababbcbbbcccccc

Test 30

Verdict:

input
10
dmq
gl
j
jqso
...

correct output
dmqgljjqsoorjjsfjtiulvw

user output
rjjsfjjqsoulvtidmqgljow

Test 31

Verdict:

input
10
a
aa
aaa
abbab
...

correct output
aaaaaaabbabbabbabbabbbbbabbbbb

user output
bbbbaabbabbbabbbabaaaaaaabbbbb

Test 32

Verdict:

input
100
aa
acmfac
afmolcn
alllbndbli
...

correct output
aaacmfacafmolcnalllbndbliamdal...

user output
jidgghdjcfjkialchjaiohlmghlkbl...
Truncated

Test 33

Verdict:

input
100
a
acjgj
ae
aegdb
...

correct output
aacjgjaeaegdbafcbahledfchagaja...

user output
kaddiffeeckjhgdaddkgifegajgahb...
Truncated

Test 34

Verdict:

input
100
a
aah
abaeeaifc
abajl
...

correct output
aaahabaeeaifcabajlaehaejcdegka...

user output
hgjlfikgeggdefellkicflglhajihk...
Truncated

Test 35

Verdict:

input
100
a
aa
abg
abndfmmmk
...

correct output
aaaabgabndfmmmkacggjdeacogeada...

user output
omohaiibmlnnfjlkinjkidbnbeccco...
Truncated

Test 36

Verdict:

input
100
afn
aic
ajrkgzldb
amcyqyh
...

correct output
afnaicajrkgzldbamcyqyhandanxhj...

user output
ylivwksxjkwlelbbpeewsjmcobofdw...
Truncated

Test 37

Verdict:

input
100
aacdeffdd
abaacbae
abfbbff
ac
...

correct output
aacdeffddabaacbaeabfbbffacacbg...

user output
fgaabadbaagaaffgccadgabffegbge...
Truncated

Test 38

Verdict:

input
100
abnfxhutgk
ajkdoqmdqp
asxeblm
badpwpsqhn
...

correct output
abnfxhutgkajkdoqmdqpasxeblmbad...

user output
wopkgngkpgkvjibcbkkeohcknqtcve...
Truncated

Test 39

Verdict:

input
100
a
aa
aaaaacaca
aaaabcabc
...

correct output
aaaaaaaacacaaaaabcabcaaabaaaab...

user output
cbcababaabccabcbabccbccacccbaa...
Truncated

Test 40

Verdict:

input
100
a
aiesfhkro
aivvkdc
ajrtj
...

correct output
aaiesfhkroaivvkdcajrtjaqfnivlb...

user output
pqvcildkfaqobarpuboimhqgiklope...
Truncated

Test 41

Verdict:

input
100
a
aa
aaaa
aaaaa
...

correct output
aaaaaaaaaaaaaaaaaaaaaaaaaaabab...

user output
baabaaaababaaaabaabbbaaabbabbb...
Truncated

Test 42

Verdict:

input
200
a
aa
abbhjifdb
acmfac
...

correct output
aaaabbhjifdbacmfacadiadnhkaehh...

user output
jidgghdjcfndfkfankbnjehgejdnhg...
Truncated

Test 43

Verdict:

input
200
a
aa
abihiahg
acjgj
...

correct output
aaaabihiahgacjgjadaeaegdbafcba...

user output
lghgjbfekakeigffgbcckaddiffeec...
Truncated

Test 44

Verdict:

input
200
a
aah
abaeeaifc
abajl
...

correct output
aaahabaeeaifcabajlaehaejcdegka...

user output
lalafbjdhihligdfefgekllhljeeji...
Truncated

Test 45

Verdict:

input
200
a
aa
aan
abg
...

correct output
aaaaanabgabndfmmmkacggjdeacoge...

user output
omnibcdnmgoeieaackfnmabjkhdcej...
Truncated

Test 46

Verdict:

input
200
ad
aegewtfc
afn
aic
...

correct output
adaegewtfcafnaicajrkgzldbamcyq...

user output
zstbqtcssaylivwksxjktntjepedpk...
Truncated

Test 47

Verdict:

input
200
a
aa
aacdeffdd
aaeceaeb
...

correct output
aaaaacdeffddaaeceaebabaacbaeab...

user output
fgaabadbaagaaffgccadgcbdfgcaga...
Truncated

Test 48

Verdict:

input
200
abnfxhutgk
aghv
ajkdoqmdqp
ajpvvalnu
...

correct output
abnfxhutgkaghvajkdoqmdqpajpvva...

user output
wopkgngkpgwhodibnhjfxjjuscklcr...
Truncated

Test 49

Verdict:

input
200
a
aa
aaaaacaca
aaaabcabc
...

correct output
aaaaaaaacacaaaaabcabcaaaacbcaa...

user output
cbcababaabccbaabcbaaccacbaabba...
Truncated

Test 50

Verdict:

input
200
a
abam
aiesfhkro
aivvkdc
...

correct output
aabamaiesfhkroaivvkdcajrtjakam...

user output
vsildonmbwsjwrgbeobipqvcildkfa...
Truncated

Test 51

Verdict:

input
200
a
aaicd
acbjfaj
achddjj
...

correct output
aaaicdacbjfajachddjjacifadaecf...

user output
kjdeeibicdkdageeaakejegfifdkdh...
Truncated

Test 52

Verdict:

input
1000
a
aa
aaccbkcd
aaj
...

correct output
aaaaaccbkcdaajaanabaabanikjabb...

user output
olhedhhkjcolgbmmkagdnkcbhiakmm...
Truncated

Test 53

Verdict:

input
1000
a
aa
aabecajcf
aabg
...

correct output
aaaaabecajcfaabgaabjllgdlkaadg...

user output
kffbegbccalibeiiedhdlhificehca...
Truncated

Test 54

Verdict:

input
1000
a
aa
aablaga
aah
...

correct output
aaaaablagaaahaajaaklkjjababaee...

user output
libbdkabebkhaibfaebelbaaacjgca...
Truncated

Test 55

Verdict:

input
1000
a
aa
aagjd
aajdlmacjn
...

correct output
aaaaagjdaajdlmacjnaakjdngdfaal...

user output
nlmkdcjabdoiddaddmamomnibcdnmg...
Truncated

Test 56

Verdict:

input
1000
a
aalguz
abcce
abggxup
...

correct output
aaalguzabcceabggxupabujabxldxy...

user output
utdcnhesdhzvohehjyotxqrribhlbp...
Truncated

Test 57

Verdict:

input
1000
a
aa
aaabaaaaf
aaaeb
...

correct output
aaaaaabaaaafaaaebaabeadaabfffd...

user output
gffecdfaabfaacabceecffcacabcaa...
Truncated

Test 58

Verdict:

input
1000
a
aamuthxggq
abnfxhutgk
adaumgqm
...

correct output
aaamuthxggqabnfxhutgkadaumgqma...

user output
xushvcllltwopkgngkpgwnfpadbaao...
Truncated

Test 59

Verdict:

input
1000
a
aa
aaa
aaaa
...

correct output
aaaaaaaaaaaaaaaaaaaaaaaaaaabaa...

user output
cbbbaaabbbcabbaaabbaccbbbbaabb...
Truncated

Test 60

Verdict:

input
1000
a
aanmhqqnpc
ab
abam
...

correct output
aaanmhqqnpcababamabginwqvvacba...

user output
wrajjcdlbcvrqntpttgpukiboelnhj...
Truncated

Test 61

Verdict:

input
1000
a
aa
aaaca
aae
...

correct output
aaaaaacaaaeaaekcaagjeahdaahhdf...

user output
kjdeeibicdkjdjgjebhjkebdgbchdg...
Truncated

Test 62

Verdict:

input
100000
a
aa
aaa
aaaagle
...

correct output
aaaaaaaaaagleaaabaaabiaaaaccgh...

user output
ojigeacefdnigedbdcedonlhikagfj...
Truncated

Test 63

Verdict:

input
100000
a
aa
aaa
aaaagf
...

correct output
aaaaaaaaaagfaaaaihlblgaaaalkll...

user output
lkjehhbdcaljiefcfcbgjigdfdbefd...
Truncated

Test 64

Verdict:

input
100000
a
aa
aaa
aaaa
...

correct output
aaaaaaaaaaaaaabkaaaaelbjbaaaaf...

user output
jhgfaddcackhecabbadaljiefgdabc...
Truncated

Test 65

Verdict:

input
100000
a
aa
aaa
aaaa
...

correct output
aaaaaaaaaaaaaahleaaaajaaabaaab...

user output
nmjhgefbbfolkjacafdconlfdiecac...
Truncated

Test 66

Verdict:

input
100000
a
aa
aaa
aaacxrqz
...

correct output
aaaaaaaaacxrqzaaahaaaahaaaplto...

user output
wtsrkpadcotpomcmjmjlzywnvqlqbe...
Truncated

Test 67

Verdict:

input
100000
a
aa
aaa
aaaa
...

correct output
aaaaaaaaaaaaaaaaaaaaaadbaaaaaa...

user output
gfebddbddbfeddcccabbgeddcbccaa...
Truncated

Test 68

Verdict:

input
100000
a
aa
aaa
aaail
...

correct output
aaaaaaaaailaaaitehaeaaaitxaaam...

user output
vrkifcebfivuoldmafkhxwvqeoueli...
Truncated

Test 69

Verdict:

input
100000
a
aa
aaa
aaaa
...

correct output
aaaaaaaaaaaaaaabghaaaabcaffaaa...

user output
igfeecaeecihgbabcfdaigdbcbcbac...
Truncated

Test 70

Verdict:

input
100000
a
aa
aaa
aaaaggo
...

correct output
aaaaaaaaaaggoaaacwpgjkvaaaftbl...

user output
vtpmhijcdcvtrqiidlchwqpoeejdbl...
Truncated

Test 71

Verdict:

input
100000
a
aa
aaa
aaaa
...

correct output
aaaaaaaaaaaaaabaaaagkaaabaaabb...

user output
jihgdcdcgckihhcedaabkjhiebfccg...
Truncated