QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#496452#4237. Word LadderCelestialCoder#AC ✓80ms3928kbC++201.1kb2024-07-28 10:34:242024-07-28 10:34:24

Judging History

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

  • [2024-07-28 10:34:24]
  • 评测
  • 测评结果:AC
  • 用时:80ms
  • 内存:3928kb
  • [2024-07-28 10:34:24]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

mt19937 rng(1010101);
int rint(int l, int r) {
    return uniform_int_distribution<int>(l, r)(rng);
}

void solve() {
    int n;
    cin >> n;

    string s;
    vector<string> ans;
    for (int i=0; i<10; ++i) s += 'a';
    ans.push_back(s);
    for (int i=1; i<n; ++i) {
        bool ok = false;
        while (!ok) {
            ok = true;
            int p = rint(0, 9);
            char ch = rint('a', 'z');
            // print(i, p, ch);
            string tmp = s;
            tmp[p] = ch;
            for (int i=(int)ans.size()-2; i>=0; --i) {
                int cnt = 0;
                for (int j=0; j<10; ++j) cnt += (tmp[j] != ans[i][j]);
                if (cnt <= 1) {
                    ok = false;
                    break;
                }
            }
            if (ok) {
                s = tmp;
                ans.push_back(s);
            }
        }
    }

    for (string t: ans) cout << t << '\n';
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    solve();
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3536kb

input:

5

output:

aaaaaaaaaa
aaaaaaamaa
aaagaaamaa
aaagaaamsa
aqagaaamsa

result:

ok good solution

Test #2:

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

input:

3

output:

aaaaaaaaaa
aaaaaaamaa
aaagaaamaa

result:

ok good solution

Test #3:

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

input:

4

output:

aaaaaaaaaa
aaaaaaamaa
aaagaaamaa
aaagaaamsa

result:

ok good solution

Test #4:

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

input:

6

output:

aaaaaaaaaa
aaaaaaamaa
aaagaaamaa
aaagaaamsa
aqagaaamsa
aqagaaajsa

result:

ok good solution

Test #5:

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

input:

7

output:

aaaaaaaaaa
aaaaaaamaa
aaagaaamaa
aaagaaamsa
aqagaaamsa
aqagaaajsa
aqagaxajsa

result:

ok good solution

Test #6:

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

input:

8

output:

aaaaaaaaaa
aaaaaaamaa
aaagaaamaa
aaagaaamsa
aqagaaamsa
aqagaaajsa
aqagaxajsa
nqagaxajsa

result:

ok good solution

Test #7:

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

input:

9

output:

aaaaaaaaaa
aaaaaaamaa
aaagaaamaa
aaagaaamsa
aqagaaamsa
aqagaaajsa
aqagaxajsa
nqagaxajsa
nqagoxajsa

result:

ok good solution

Test #8:

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

input:

10

output:

aaaaaaaaaa
aaaaaaamaa
aaagaaamaa
aaagaaamsa
aqagaaamsa
aqagaaajsa
aqagaxajsa
nqagaxajsa
nqagoxajsa
nzagoxajsa

result:

ok good solution

Test #9:

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

input:

64

output:

aaaaaaaaaa
aaaaaaamaa
aaagaaamaa
aaagaaamsa
aqagaaamsa
aqagaaajsa
aqagaxajsa
nqagaxajsa
nqagoxajsa
nzagoxajsa
nzagoxajsz
nzagyxajsz
nzayyxajsz
nzayyxajsx
azayyxajsx
azayyxaqsx
azxyyxaqsx
azxyyxaisx
azxyyxwisx
azxyyzwisx
azxyyzwisd
azxykzwisd
azdykzwisd
xzdykzwisd
xzddkzwisd
xzddkzwixd
xzmdkzwixd
xam...

result:

ok good solution

Test #10:

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

input:

51

output:

aaaaaaaaaa
aaaaaaamaa
aaagaaamaa
aaagaaamsa
aqagaaamsa
aqagaaajsa
aqagaxajsa
nqagaxajsa
nqagoxajsa
nzagoxajsa
nzagoxajsz
nzagyxajsz
nzayyxajsz
nzayyxajsx
azayyxajsx
azayyxaqsx
azxyyxaqsx
azxyyxaisx
azxyyxwisx
azxyyzwisx
azxyyzwisd
azxykzwisd
azdykzwisd
xzdykzwisd
xzddkzwisd
xzddkzwixd
xzmdkzwixd
xam...

result:

ok good solution

Test #11:

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

input:

97

output:

aaaaaaaaaa
aaaaaaamaa
aaagaaamaa
aaagaaamsa
aqagaaamsa
aqagaaajsa
aqagaxajsa
nqagaxajsa
nqagoxajsa
nzagoxajsa
nzagoxajsz
nzagyxajsz
nzayyxajsz
nzayyxajsx
azayyxajsx
azayyxaqsx
azxyyxaqsx
azxyyxaisx
azxyyxwisx
azxyyzwisx
azxyyzwisd
azxykzwisd
azdykzwisd
xzdykzwisd
xzddkzwisd
xzddkzwixd
xzmdkzwixd
xam...

result:

ok good solution

Test #12:

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

input:

100

output:

aaaaaaaaaa
aaaaaaamaa
aaagaaamaa
aaagaaamsa
aqagaaamsa
aqagaaajsa
aqagaxajsa
nqagaxajsa
nqagoxajsa
nzagoxajsa
nzagoxajsz
nzagyxajsz
nzayyxajsz
nzayyxajsx
azayyxajsx
azayyxaqsx
azxyyxaqsx
azxyyxaisx
azxyyxwisx
azxyyzwisx
azxyyzwisd
azxykzwisd
azdykzwisd
xzdykzwisd
xzddkzwisd
xzddkzwixd
xzmdkzwixd
xam...

result:

ok good solution

Test #13:

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

input:

1000

output:

aaaaaaaaaa
aaaaaaamaa
aaagaaamaa
aaagaaamsa
aqagaaamsa
aqagaaajsa
aqagaxajsa
nqagaxajsa
nqagoxajsa
nzagoxajsa
nzagoxajsz
nzagyxajsz
nzayyxajsz
nzayyxajsx
azayyxajsx
azayyxaqsx
azxyyxaqsx
azxyyxaisx
azxyyxwisx
azxyyzwisx
azxyyzwisd
azxykzwisd
azdykzwisd
xzdykzwisd
xzddkzwisd
xzddkzwixd
xzmdkzwixd
xam...

result:

ok good solution

Test #14:

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

input:

1001

output:

aaaaaaaaaa
aaaaaaamaa
aaagaaamaa
aaagaaamsa
aqagaaamsa
aqagaaajsa
aqagaxajsa
nqagaxajsa
nqagoxajsa
nzagoxajsa
nzagoxajsz
nzagyxajsz
nzayyxajsz
nzayyxajsx
azayyxajsx
azayyxaqsx
azxyyxaqsx
azxyyxaisx
azxyyxwisx
azxyyzwisx
azxyyzwisd
azxykzwisd
azdykzwisd
xzdykzwisd
xzddkzwisd
xzddkzwixd
xzmdkzwixd
xam...

result:

ok good solution

Test #15:

score: 0
Accepted
time: 4ms
memory: 3600kb

input:

1024

output:

aaaaaaaaaa
aaaaaaamaa
aaagaaamaa
aaagaaamsa
aqagaaamsa
aqagaaajsa
aqagaxajsa
nqagaxajsa
nqagoxajsa
nzagoxajsa
nzagoxajsz
nzagyxajsz
nzayyxajsz
nzayyxajsx
azayyxajsx
azayyxaqsx
azxyyxaqsx
azxyyxaisx
azxyyxwisx
azxyyzwisx
azxyyzwisd
azxykzwisd
azdykzwisd
xzdykzwisd
xzddkzwisd
xzddkzwixd
xzmdkzwixd
xam...

result:

ok good solution

Test #16:

score: 0
Accepted
time: 4ms
memory: 3928kb

input:

1025

output:

aaaaaaaaaa
aaaaaaamaa
aaagaaamaa
aaagaaamsa
aqagaaamsa
aqagaaajsa
aqagaxajsa
nqagaxajsa
nqagoxajsa
nzagoxajsa
nzagoxajsz
nzagyxajsz
nzayyxajsz
nzayyxajsx
azayyxajsx
azayyxaqsx
azxyyxaqsx
azxyyxaisx
azxyyxwisx
azxyyzwisx
azxyyzwisd
azxykzwisd
azdykzwisd
xzdykzwisd
xzddkzwisd
xzddkzwixd
xzmdkzwixd
xam...

result:

ok good solution

Test #17:

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

input:

5000

output:

aaaaaaaaaa
aaaaaaamaa
aaagaaamaa
aaagaaamsa
aqagaaamsa
aqagaaajsa
aqagaxajsa
nqagaxajsa
nqagoxajsa
nzagoxajsa
nzagoxajsz
nzagyxajsz
nzayyxajsz
nzayyxajsx
azayyxajsx
azayyxaqsx
azxyyxaqsx
azxyyxaisx
azxyyxwisx
azxyyzwisx
azxyyzwisd
azxykzwisd
azdykzwisd
xzdykzwisd
xzddkzwisd
xzddkzwixd
xzmdkzwixd
xam...

result:

ok good solution

Test #18:

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

input:

4999

output:

aaaaaaaaaa
aaaaaaamaa
aaagaaamaa
aaagaaamsa
aqagaaamsa
aqagaaajsa
aqagaxajsa
nqagaxajsa
nqagoxajsa
nzagoxajsa
nzagoxajsz
nzagyxajsz
nzayyxajsz
nzayyxajsx
azayyxajsx
azayyxaqsx
azxyyxaqsx
azxyyxaisx
azxyyxwisx
azxyyzwisx
azxyyzwisd
azxykzwisd
azdykzwisd
xzdykzwisd
xzddkzwisd
xzddkzwixd
xzmdkzwixd
xam...

result:

ok good solution

Test #19:

score: 0
Accepted
time: 55ms
memory: 3736kb

input:

4096

output:

aaaaaaaaaa
aaaaaaamaa
aaagaaamaa
aaagaaamsa
aqagaaamsa
aqagaaajsa
aqagaxajsa
nqagaxajsa
nqagoxajsa
nzagoxajsa
nzagoxajsz
nzagyxajsz
nzayyxajsz
nzayyxajsx
azayyxajsx
azayyxaqsx
azxyyxaqsx
azxyyxaisx
azxyyxwisx
azxyyzwisx
azxyyzwisd
azxykzwisd
azdykzwisd
xzdykzwisd
xzddkzwisd
xzddkzwixd
xzmdkzwixd
xam...

result:

ok good solution

Test #20:

score: 0
Accepted
time: 54ms
memory: 3696kb

input:

4097

output:

aaaaaaaaaa
aaaaaaamaa
aaagaaamaa
aaagaaamsa
aqagaaamsa
aqagaaajsa
aqagaxajsa
nqagaxajsa
nqagoxajsa
nzagoxajsa
nzagoxajsz
nzagyxajsz
nzayyxajsz
nzayyxajsx
azayyxajsx
azayyxaqsx
azxyyxaqsx
azxyyxaisx
azxyyxwisx
azxyyzwisx
azxyyzwisd
azxykzwisd
azdykzwisd
xzdykzwisd
xzddkzwisd
xzddkzwixd
xzmdkzwixd
xam...

result:

ok good solution

Test #21:

score: 0
Accepted
time: 54ms
memory: 3724kb

input:

4098

output:

aaaaaaaaaa
aaaaaaamaa
aaagaaamaa
aaagaaamsa
aqagaaamsa
aqagaaajsa
aqagaxajsa
nqagaxajsa
nqagoxajsa
nzagoxajsa
nzagoxajsz
nzagyxajsz
nzayyxajsz
nzayyxajsx
azayyxajsx
azayyxaqsx
azxyyxaqsx
azxyyxaisx
azxyyxwisx
azxyyzwisx
azxyyzwisd
azxykzwisd
azdykzwisd
xzdykzwisd
xzddkzwisd
xzddkzwixd
xzmdkzwixd
xam...

result:

ok good solution

Test #22:

score: 0
Accepted
time: 45ms
memory: 3728kb

input:

3751

output:

aaaaaaaaaa
aaaaaaamaa
aaagaaamaa
aaagaaamsa
aqagaaamsa
aqagaaajsa
aqagaxajsa
nqagaxajsa
nqagoxajsa
nzagoxajsa
nzagoxajsz
nzagyxajsz
nzayyxajsz
nzayyxajsx
azayyxajsx
azayyxaqsx
azxyyxaqsx
azxyyxaisx
azxyyxwisx
azxyyzwisx
azxyyzwisd
azxykzwisd
azdykzwisd
xzdykzwisd
xzddkzwisd
xzddkzwixd
xzmdkzwixd
xam...

result:

ok good solution