QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#86547#4237. Word Laddercardinal_city#AC ✓3ms3716kbC++201.5kb2023-03-10 06:12:052023-03-10 06:12:08

Judging History

你现在查看的是最新测评结果

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-03-10 06:12:08]
  • 评测
  • 测评结果:AC
  • 用时:3ms
  • 内存:3716kb
  • [2023-03-10 06:12:05]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;

#define all(x) (x).begin(), (x).end()

int main() {
    cin.tie(0)->sync_with_stdio(0);

    int n;
    cin >> n;
    
    vector<string> forward;
    for (char i = 'a'; i < 'z'; i++) {
        string s = "aa";
        s[0] = i;
        s[1] = i;
        forward.push_back(s);
        s[1] = i + 1;
        forward.push_back(s);
    }
    forward.push_back("zz");

    cout << "\n";
    
    vector<string> words;
    for (auto& k : forward) {
        words.push_back("aa" + k);
    }


    for (int i = 'a'; i < 'z'; i++) {
        string s = "aa";
        s[0] = i;
        s[1] = i + 1;
        words.push_back(s + forward.back());
        reverse(all(forward));
        s[0] = i + 1;
        for (auto& k : forward) {
            words.push_back(s + k);
        }
    }

    vector<string> wordCp = words;
    for (int j = 'a'; j < 'f'; j++) {
        string s1 = "aa";
        s1[0] = j;
        s1[1] = j + 1;
        words.push_back(s1 + wordCp.back());
        reverse(all(wordCp));
        s1[0] = j + 1;
        for (auto& k : wordCp) {
            words.push_back(s1 + k);
        }
    }

    for (auto& k : words) {
        if (k.size() < 6) {
            k = "aa" + k;
        }
    }

    assert(words.size() >= n);
    words.resize(n);

    // cout << words.size() << "\n";
    for (auto& k : words) {
        cout << k << "\n";
    }

    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 3ms
memory: 3660kb

input:

5

output:


aaaaaa
aaaaab
aaaabb
aaaabc
aaaacc

result:

ok good solution

Test #2:

score: 0
Accepted
time: 3ms
memory: 3612kb

input:

3

output:


aaaaaa
aaaaab
aaaabb

result:

ok good solution

Test #3:

score: 0
Accepted
time: 0ms
memory: 3644kb

input:

4

output:


aaaaaa
aaaaab
aaaabb
aaaabc

result:

ok good solution

Test #4:

score: 0
Accepted
time: 3ms
memory: 3644kb

input:

6

output:


aaaaaa
aaaaab
aaaabb
aaaabc
aaaacc
aaaacd

result:

ok good solution

Test #5:

score: 0
Accepted
time: 2ms
memory: 3668kb

input:

7

output:


aaaaaa
aaaaab
aaaabb
aaaabc
aaaacc
aaaacd
aaaadd

result:

ok good solution

Test #6:

score: 0
Accepted
time: 1ms
memory: 3580kb

input:

8

output:


aaaaaa
aaaaab
aaaabb
aaaabc
aaaacc
aaaacd
aaaadd
aaaade

result:

ok good solution

Test #7:

score: 0
Accepted
time: 3ms
memory: 3612kb

input:

9

output:


aaaaaa
aaaaab
aaaabb
aaaabc
aaaacc
aaaacd
aaaadd
aaaade
aaaaee

result:

ok good solution

Test #8:

score: 0
Accepted
time: 1ms
memory: 3608kb

input:

10

output:


aaaaaa
aaaaab
aaaabb
aaaabc
aaaacc
aaaacd
aaaadd
aaaade
aaaaee
aaaaef

result:

ok good solution

Test #9:

score: 0
Accepted
time: 1ms
memory: 3608kb

input:

64

output:


aaaaaa
aaaaab
aaaabb
aaaabc
aaaacc
aaaacd
aaaadd
aaaade
aaaaee
aaaaef
aaaaff
aaaafg
aaaagg
aaaagh
aaaahh
aaaahi
aaaaii
aaaaij
aaaajj
aaaajk
aaaakk
aaaakl
aaaall
aaaalm
aaaamm
aaaamn
aaaann
aaaano
aaaaoo
aaaaop
aaaapp
aaaapq
aaaaqq
aaaaqr
aaaarr
aaaars
aaaass
aaaast
aaaatt
aaaatu
aaaauu
aaaauv
aaaav...

result:

ok good solution

Test #10:

score: 0
Accepted
time: 3ms
memory: 3660kb

input:

51

output:


aaaaaa
aaaaab
aaaabb
aaaabc
aaaacc
aaaacd
aaaadd
aaaade
aaaaee
aaaaef
aaaaff
aaaafg
aaaagg
aaaagh
aaaahh
aaaahi
aaaaii
aaaaij
aaaajj
aaaajk
aaaakk
aaaakl
aaaall
aaaalm
aaaamm
aaaamn
aaaann
aaaano
aaaaoo
aaaaop
aaaapp
aaaapq
aaaaqq
aaaaqr
aaaarr
aaaars
aaaass
aaaast
aaaatt
aaaatu
aaaauu
aaaauv
aaaav...

result:

ok good solution

Test #11:

score: 0
Accepted
time: 1ms
memory: 3632kb

input:

97

output:


aaaaaa
aaaaab
aaaabb
aaaabc
aaaacc
aaaacd
aaaadd
aaaade
aaaaee
aaaaef
aaaaff
aaaafg
aaaagg
aaaagh
aaaahh
aaaahi
aaaaii
aaaaij
aaaajj
aaaajk
aaaakk
aaaakl
aaaall
aaaalm
aaaamm
aaaamn
aaaann
aaaano
aaaaoo
aaaaop
aaaapp
aaaapq
aaaaqq
aaaaqr
aaaarr
aaaars
aaaass
aaaast
aaaatt
aaaatu
aaaauu
aaaauv
aaaav...

result:

ok good solution

Test #12:

score: 0
Accepted
time: 2ms
memory: 3712kb

input:

100

output:


aaaaaa
aaaaab
aaaabb
aaaabc
aaaacc
aaaacd
aaaadd
aaaade
aaaaee
aaaaef
aaaaff
aaaafg
aaaagg
aaaagh
aaaahh
aaaahi
aaaaii
aaaaij
aaaajj
aaaajk
aaaakk
aaaakl
aaaall
aaaalm
aaaamm
aaaamn
aaaann
aaaano
aaaaoo
aaaaop
aaaapp
aaaapq
aaaaqq
aaaaqr
aaaarr
aaaars
aaaass
aaaast
aaaatt
aaaatu
aaaauu
aaaauv
aaaav...

result:

ok good solution

Test #13:

score: 0
Accepted
time: 3ms
memory: 3604kb

input:

1000

output:


aaaaaa
aaaaab
aaaabb
aaaabc
aaaacc
aaaacd
aaaadd
aaaade
aaaaee
aaaaef
aaaaff
aaaafg
aaaagg
aaaagh
aaaahh
aaaahi
aaaaii
aaaaij
aaaajj
aaaajk
aaaakk
aaaakl
aaaall
aaaalm
aaaamm
aaaamn
aaaann
aaaano
aaaaoo
aaaaop
aaaapp
aaaapq
aaaaqq
aaaaqr
aaaarr
aaaars
aaaass
aaaast
aaaatt
aaaatu
aaaauu
aaaauv
aaaav...

result:

ok good solution

Test #14:

score: 0
Accepted
time: 2ms
memory: 3604kb

input:

1001

output:


aaaaaa
aaaaab
aaaabb
aaaabc
aaaacc
aaaacd
aaaadd
aaaade
aaaaee
aaaaef
aaaaff
aaaafg
aaaagg
aaaagh
aaaahh
aaaahi
aaaaii
aaaaij
aaaajj
aaaajk
aaaakk
aaaakl
aaaall
aaaalm
aaaamm
aaaamn
aaaann
aaaano
aaaaoo
aaaaop
aaaapp
aaaapq
aaaaqq
aaaaqr
aaaarr
aaaars
aaaass
aaaast
aaaatt
aaaatu
aaaauu
aaaauv
aaaav...

result:

ok good solution

Test #15:

score: 0
Accepted
time: 0ms
memory: 3588kb

input:

1024

output:


aaaaaa
aaaaab
aaaabb
aaaabc
aaaacc
aaaacd
aaaadd
aaaade
aaaaee
aaaaef
aaaaff
aaaafg
aaaagg
aaaagh
aaaahh
aaaahi
aaaaii
aaaaij
aaaajj
aaaajk
aaaakk
aaaakl
aaaall
aaaalm
aaaamm
aaaamn
aaaann
aaaano
aaaaoo
aaaaop
aaaapp
aaaapq
aaaaqq
aaaaqr
aaaarr
aaaars
aaaass
aaaast
aaaatt
aaaatu
aaaauu
aaaauv
aaaav...

result:

ok good solution

Test #16:

score: 0
Accepted
time: 0ms
memory: 3592kb

input:

1025

output:


aaaaaa
aaaaab
aaaabb
aaaabc
aaaacc
aaaacd
aaaadd
aaaade
aaaaee
aaaaef
aaaaff
aaaafg
aaaagg
aaaagh
aaaahh
aaaahi
aaaaii
aaaaij
aaaajj
aaaajk
aaaakk
aaaakl
aaaall
aaaalm
aaaamm
aaaamn
aaaann
aaaano
aaaaoo
aaaaop
aaaapp
aaaapq
aaaaqq
aaaaqr
aaaarr
aaaars
aaaass
aaaast
aaaatt
aaaatu
aaaauu
aaaauv
aaaav...

result:

ok good solution

Test #17:

score: 0
Accepted
time: 1ms
memory: 3616kb

input:

5000

output:


aaaaaa
aaaaab
aaaabb
aaaabc
aaaacc
aaaacd
aaaadd
aaaade
aaaaee
aaaaef
aaaaff
aaaafg
aaaagg
aaaagh
aaaahh
aaaahi
aaaaii
aaaaij
aaaajj
aaaajk
aaaakk
aaaakl
aaaall
aaaalm
aaaamm
aaaamn
aaaann
aaaano
aaaaoo
aaaaop
aaaapp
aaaapq
aaaaqq
aaaaqr
aaaarr
aaaars
aaaass
aaaast
aaaatt
aaaatu
aaaauu
aaaauv
aaaav...

result:

ok good solution

Test #18:

score: 0
Accepted
time: 1ms
memory: 3716kb

input:

4999

output:


aaaaaa
aaaaab
aaaabb
aaaabc
aaaacc
aaaacd
aaaadd
aaaade
aaaaee
aaaaef
aaaaff
aaaafg
aaaagg
aaaagh
aaaahh
aaaahi
aaaaii
aaaaij
aaaajj
aaaajk
aaaakk
aaaakl
aaaall
aaaalm
aaaamm
aaaamn
aaaann
aaaano
aaaaoo
aaaaop
aaaapp
aaaapq
aaaaqq
aaaaqr
aaaarr
aaaars
aaaass
aaaast
aaaatt
aaaatu
aaaauu
aaaauv
aaaav...

result:

ok good solution

Test #19:

score: 0
Accepted
time: 3ms
memory: 3588kb

input:

4096

output:


aaaaaa
aaaaab
aaaabb
aaaabc
aaaacc
aaaacd
aaaadd
aaaade
aaaaee
aaaaef
aaaaff
aaaafg
aaaagg
aaaagh
aaaahh
aaaahi
aaaaii
aaaaij
aaaajj
aaaajk
aaaakk
aaaakl
aaaall
aaaalm
aaaamm
aaaamn
aaaann
aaaano
aaaaoo
aaaaop
aaaapp
aaaapq
aaaaqq
aaaaqr
aaaarr
aaaars
aaaass
aaaast
aaaatt
aaaatu
aaaauu
aaaauv
aaaav...

result:

ok good solution

Test #20:

score: 0
Accepted
time: 3ms
memory: 3572kb

input:

4097

output:


aaaaaa
aaaaab
aaaabb
aaaabc
aaaacc
aaaacd
aaaadd
aaaade
aaaaee
aaaaef
aaaaff
aaaafg
aaaagg
aaaagh
aaaahh
aaaahi
aaaaii
aaaaij
aaaajj
aaaajk
aaaakk
aaaakl
aaaall
aaaalm
aaaamm
aaaamn
aaaann
aaaano
aaaaoo
aaaaop
aaaapp
aaaapq
aaaaqq
aaaaqr
aaaarr
aaaars
aaaass
aaaast
aaaatt
aaaatu
aaaauu
aaaauv
aaaav...

result:

ok good solution

Test #21:

score: 0
Accepted
time: 1ms
memory: 3616kb

input:

4098

output:


aaaaaa
aaaaab
aaaabb
aaaabc
aaaacc
aaaacd
aaaadd
aaaade
aaaaee
aaaaef
aaaaff
aaaafg
aaaagg
aaaagh
aaaahh
aaaahi
aaaaii
aaaaij
aaaajj
aaaajk
aaaakk
aaaakl
aaaall
aaaalm
aaaamm
aaaamn
aaaann
aaaano
aaaaoo
aaaaop
aaaapp
aaaapq
aaaaqq
aaaaqr
aaaarr
aaaars
aaaass
aaaast
aaaatt
aaaatu
aaaauu
aaaauv
aaaav...

result:

ok good solution

Test #22:

score: 0
Accepted
time: 3ms
memory: 3680kb

input:

3751

output:


aaaaaa
aaaaab
aaaabb
aaaabc
aaaacc
aaaacd
aaaadd
aaaade
aaaaee
aaaaef
aaaaff
aaaafg
aaaagg
aaaagh
aaaahh
aaaahi
aaaaii
aaaaij
aaaajj
aaaajk
aaaakk
aaaakl
aaaall
aaaalm
aaaamm
aaaamn
aaaann
aaaano
aaaaoo
aaaaop
aaaapp
aaaapq
aaaaqq
aaaaqr
aaaarr
aaaars
aaaass
aaaast
aaaatt
aaaatu
aaaauu
aaaauv
aaaav...

result:

ok good solution