QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#100092#4237. Word LadderRoomGamadan#AC ✓3ms3620kbC++231.5kb2023-04-24 17:38:352023-04-24 17:38:37

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-04-24 17:38:37]
  • 评测
  • 测评结果:AC
  • 用时:3ms
  • 内存:3620kb
  • [2023-04-24 17:38:35]
  • 提交

answer

#pragma GCC optimize("Ofast")
#pragma GCC optimize("O3")

#include <bits/stdc++.h>
using namespace std;

#define el '\n'
#define F first
#define S second

typedef long long ll;
typedef long double ld;

bool multipleTestCases = 0, sublime = 1;
const int N = 1e6 + 5, INF = 1e9 + 5, mod = 1e9 + 7, LOG = 22, SQ = 500;


string f = "aa", s = "aaaaaaaa";
vector<string> v = {f + s};

void inc() {
    for(int j = 0; j < 25; j++) {
        for (int i = 0; i < 8; i++) {
            s[i]++;
            v.push_back(f + s);
        }
    }
}

void dec() {
    for(int j = 0; j < 25; j++) {
        for (int i = 0; i < 8; i++) {
            s[i]--;
            v.push_back(f + s);
        }
    }
}


void doWork() {
    while (v.size() < 5e3) {
        inc();
        f[0]++;
        v.push_back(f + s);
        f[1]++;
        v.push_back(f + s);
        dec();
        f[0]++;
        v.push_back(f + s);
        f[1]++;
        v.push_back(f + s);
    }

    int n;
    cin >> n;
    for (int i = 0; i < n; i++) {
        cout << v[i] << el;
    }
}

signed main() {
#ifdef ONLINE_JUDGE
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#endif
#ifndef ONLINE_JUDGE
    if (sublime) {
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    }
#endif
    int tests = 1;
    if (multipleTestCases) {
        cin >> tests;
    }
    for (int tc = 1; tc <= tests; tc++) {
        doWork();
    }
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 2ms
memory: 3508kb

input:

5

output:

aaaaaaaaaa
aabaaaaaaa
aabbaaaaaa
aabbbaaaaa
aabbbbaaaa

result:

ok good solution

Test #2:

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

input:

3

output:

aaaaaaaaaa
aabaaaaaaa
aabbaaaaaa

result:

ok good solution

Test #3:

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

input:

4

output:

aaaaaaaaaa
aabaaaaaaa
aabbaaaaaa
aabbbaaaaa

result:

ok good solution

Test #4:

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

input:

6

output:

aaaaaaaaaa
aabaaaaaaa
aabbaaaaaa
aabbbaaaaa
aabbbbaaaa
aabbbbbaaa

result:

ok good solution

Test #5:

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

input:

7

output:

aaaaaaaaaa
aabaaaaaaa
aabbaaaaaa
aabbbaaaaa
aabbbbaaaa
aabbbbbaaa
aabbbbbbaa

result:

ok good solution

Test #6:

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

input:

8

output:

aaaaaaaaaa
aabaaaaaaa
aabbaaaaaa
aabbbaaaaa
aabbbbaaaa
aabbbbbaaa
aabbbbbbaa
aabbbbbbba

result:

ok good solution

Test #7:

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

input:

9

output:

aaaaaaaaaa
aabaaaaaaa
aabbaaaaaa
aabbbaaaaa
aabbbbaaaa
aabbbbbaaa
aabbbbbbaa
aabbbbbbba
aabbbbbbbb

result:

ok good solution

Test #8:

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

input:

10

output:

aaaaaaaaaa
aabaaaaaaa
aabbaaaaaa
aabbbaaaaa
aabbbbaaaa
aabbbbbaaa
aabbbbbbaa
aabbbbbbba
aabbbbbbbb
aacbbbbbbb

result:

ok good solution

Test #9:

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

input:

64

output:

aaaaaaaaaa
aabaaaaaaa
aabbaaaaaa
aabbbaaaaa
aabbbbaaaa
aabbbbbaaa
aabbbbbbaa
aabbbbbbba
aabbbbbbbb
aacbbbbbbb
aaccbbbbbb
aacccbbbbb
aaccccbbbb
aacccccbbb
aaccccccbb
aacccccccb
aacccccccc
aadccccccc
aaddcccccc
aadddccccc
aaddddcccc
aadddddccc
aaddddddcc
aadddddddc
aadddddddd
aaeddddddd
aaeedddddd
aae...

result:

ok good solution

Test #10:

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

input:

51

output:

aaaaaaaaaa
aabaaaaaaa
aabbaaaaaa
aabbbaaaaa
aabbbbaaaa
aabbbbbaaa
aabbbbbbaa
aabbbbbbba
aabbbbbbbb
aacbbbbbbb
aaccbbbbbb
aacccbbbbb
aaccccbbbb
aacccccbbb
aaccccccbb
aacccccccb
aacccccccc
aadccccccc
aaddcccccc
aadddccccc
aaddddcccc
aadddddccc
aaddddddcc
aadddddddc
aadddddddd
aaeddddddd
aaeedddddd
aae...

result:

ok good solution

Test #11:

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

input:

97

output:

aaaaaaaaaa
aabaaaaaaa
aabbaaaaaa
aabbbaaaaa
aabbbbaaaa
aabbbbbaaa
aabbbbbbaa
aabbbbbbba
aabbbbbbbb
aacbbbbbbb
aaccbbbbbb
aacccbbbbb
aaccccbbbb
aacccccbbb
aaccccccbb
aacccccccb
aacccccccc
aadccccccc
aaddcccccc
aadddccccc
aaddddcccc
aadddddccc
aaddddddcc
aadddddddc
aadddddddd
aaeddddddd
aaeedddddd
aae...

result:

ok good solution

Test #12:

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

input:

100

output:

aaaaaaaaaa
aabaaaaaaa
aabbaaaaaa
aabbbaaaaa
aabbbbaaaa
aabbbbbaaa
aabbbbbbaa
aabbbbbbba
aabbbbbbbb
aacbbbbbbb
aaccbbbbbb
aacccbbbbb
aaccccbbbb
aacccccbbb
aaccccccbb
aacccccccb
aacccccccc
aadccccccc
aaddcccccc
aadddccccc
aaddddcccc
aadddddccc
aaddddddcc
aadddddddc
aadddddddd
aaeddddddd
aaeedddddd
aae...

result:

ok good solution

Test #13:

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

input:

1000

output:

aaaaaaaaaa
aabaaaaaaa
aabbaaaaaa
aabbbaaaaa
aabbbbaaaa
aabbbbbaaa
aabbbbbbaa
aabbbbbbba
aabbbbbbbb
aacbbbbbbb
aaccbbbbbb
aacccbbbbb
aaccccbbbb
aacccccbbb
aaccccccbb
aacccccccb
aacccccccc
aadccccccc
aaddcccccc
aadddccccc
aaddddcccc
aadddddccc
aaddddddcc
aadddddddc
aadddddddd
aaeddddddd
aaeedddddd
aae...

result:

ok good solution

Test #14:

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

input:

1001

output:

aaaaaaaaaa
aabaaaaaaa
aabbaaaaaa
aabbbaaaaa
aabbbbaaaa
aabbbbbaaa
aabbbbbbaa
aabbbbbbba
aabbbbbbbb
aacbbbbbbb
aaccbbbbbb
aacccbbbbb
aaccccbbbb
aacccccbbb
aaccccccbb
aacccccccb
aacccccccc
aadccccccc
aaddcccccc
aadddccccc
aaddddcccc
aadddddccc
aaddddddcc
aadddddddc
aadddddddd
aaeddddddd
aaeedddddd
aae...

result:

ok good solution

Test #15:

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

input:

1024

output:

aaaaaaaaaa
aabaaaaaaa
aabbaaaaaa
aabbbaaaaa
aabbbbaaaa
aabbbbbaaa
aabbbbbbaa
aabbbbbbba
aabbbbbbbb
aacbbbbbbb
aaccbbbbbb
aacccbbbbb
aaccccbbbb
aacccccbbb
aaccccccbb
aacccccccb
aacccccccc
aadccccccc
aaddcccccc
aadddccccc
aaddddcccc
aadddddccc
aaddddddcc
aadddddddc
aadddddddd
aaeddddddd
aaeedddddd
aae...

result:

ok good solution

Test #16:

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

input:

1025

output:

aaaaaaaaaa
aabaaaaaaa
aabbaaaaaa
aabbbaaaaa
aabbbbaaaa
aabbbbbaaa
aabbbbbbaa
aabbbbbbba
aabbbbbbbb
aacbbbbbbb
aaccbbbbbb
aacccbbbbb
aaccccbbbb
aacccccbbb
aaccccccbb
aacccccccb
aacccccccc
aadccccccc
aaddcccccc
aadddccccc
aaddddcccc
aadddddccc
aaddddddcc
aadddddddc
aadddddddd
aaeddddddd
aaeedddddd
aae...

result:

ok good solution

Test #17:

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

input:

5000

output:

aaaaaaaaaa
aabaaaaaaa
aabbaaaaaa
aabbbaaaaa
aabbbbaaaa
aabbbbbaaa
aabbbbbbaa
aabbbbbbba
aabbbbbbbb
aacbbbbbbb
aaccbbbbbb
aacccbbbbb
aaccccbbbb
aacccccbbb
aaccccccbb
aacccccccb
aacccccccc
aadccccccc
aaddcccccc
aadddccccc
aaddddcccc
aadddddccc
aaddddddcc
aadddddddc
aadddddddd
aaeddddddd
aaeedddddd
aae...

result:

ok good solution

Test #18:

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

input:

4999

output:

aaaaaaaaaa
aabaaaaaaa
aabbaaaaaa
aabbbaaaaa
aabbbbaaaa
aabbbbbaaa
aabbbbbbaa
aabbbbbbba
aabbbbbbbb
aacbbbbbbb
aaccbbbbbb
aacccbbbbb
aaccccbbbb
aacccccbbb
aaccccccbb
aacccccccb
aacccccccc
aadccccccc
aaddcccccc
aadddccccc
aaddddcccc
aadddddccc
aaddddddcc
aadddddddc
aadddddddd
aaeddddddd
aaeedddddd
aae...

result:

ok good solution

Test #19:

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

input:

4096

output:

aaaaaaaaaa
aabaaaaaaa
aabbaaaaaa
aabbbaaaaa
aabbbbaaaa
aabbbbbaaa
aabbbbbbaa
aabbbbbbba
aabbbbbbbb
aacbbbbbbb
aaccbbbbbb
aacccbbbbb
aaccccbbbb
aacccccbbb
aaccccccbb
aacccccccb
aacccccccc
aadccccccc
aaddcccccc
aadddccccc
aaddddcccc
aadddddccc
aaddddddcc
aadddddddc
aadddddddd
aaeddddddd
aaeedddddd
aae...

result:

ok good solution

Test #20:

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

input:

4097

output:

aaaaaaaaaa
aabaaaaaaa
aabbaaaaaa
aabbbaaaaa
aabbbbaaaa
aabbbbbaaa
aabbbbbbaa
aabbbbbbba
aabbbbbbbb
aacbbbbbbb
aaccbbbbbb
aacccbbbbb
aaccccbbbb
aacccccbbb
aaccccccbb
aacccccccb
aacccccccc
aadccccccc
aaddcccccc
aadddccccc
aaddddcccc
aadddddccc
aaddddddcc
aadddddddc
aadddddddd
aaeddddddd
aaeedddddd
aae...

result:

ok good solution

Test #21:

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

input:

4098

output:

aaaaaaaaaa
aabaaaaaaa
aabbaaaaaa
aabbbaaaaa
aabbbbaaaa
aabbbbbaaa
aabbbbbbaa
aabbbbbbba
aabbbbbbbb
aacbbbbbbb
aaccbbbbbb
aacccbbbbb
aaccccbbbb
aacccccbbb
aaccccccbb
aacccccccb
aacccccccc
aadccccccc
aaddcccccc
aadddccccc
aaddddcccc
aadddddccc
aaddddddcc
aadddddddc
aadddddddd
aaeddddddd
aaeedddddd
aae...

result:

ok good solution

Test #22:

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

input:

3751

output:

aaaaaaaaaa
aabaaaaaaa
aabbaaaaaa
aabbbaaaaa
aabbbbaaaa
aabbbbbaaa
aabbbbbbaa
aabbbbbbba
aabbbbbbbb
aacbbbbbbb
aaccbbbbbb
aacccbbbbb
aaccccbbbb
aacccccbbb
aaccccccbb
aacccccccb
aacccccccc
aadccccccc
aaddcccccc
aadddccccc
aaddddcccc
aadddddccc
aaddddddcc
aadddddddc
aadddddddd
aaeddddddd
aaeedddddd
aae...

result:

ok good solution