QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#847931#4237. Word LadderHeyJinhwi#AC ✓2ms4504kbC++14961b2025-01-08 13:36:202025-01-08 13:36:20

Judging History

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

  • [2025-01-08 13:36:20]
  • 评测
  • 测评结果:AC
  • 用时:2ms
  • 内存:4504kb
  • [2025-01-08 13:36:20]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
int v[26][26][26][26];
vector<int> ans;
void dfs(int a,int b,int c,int d)
{
    if(ans.size()>=5000)return;
    v[a][b][c][d]=1;
    ans.push_back(a+b*26+c*26*26+d*26*26*26);
    for(int i=0;i<26;i++)
    {
        if(v[i][b][c][d]==0)
        {
            dfs(i,b,c,d);
        }
        if(v[a][i][c][d]==0)
        {
            dfs(a,i,c,d);
        }
        if(v[a][b][i][d]==0)
        {
            dfs(a,b,i,d);
        }
        if(v[a][b][c][i]==0)
        {
            dfs(a,b,c,i);
        }
    }
}
main()
{
    dfs(0,0,0,0);
    int n;cin>>n;
    for(int i=0;i<n;i++)
    {
        int x=ans[i/2],y=ans[(i+1)/2];
        for(int j=0;j<4;j++)
        {
            cout<<(char)(x%26+'a');
            x/=26;
        }
        for(int j=0;j<4;j++)
        {
            cout<<(char)(y%26+'a');
            y/=26;
        }
        cout<<'\n';
    }
}

详细

Test #1:

score: 100
Accepted
time: 1ms
memory: 4504kb

input:

5

output:

aaaaaaaa
aaaabaaa
baaabaaa
baaabbaa
bbaabbaa

result:

ok good solution

Test #2:

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

input:

3

output:

aaaaaaaa
aaaabaaa
baaabaaa

result:

ok good solution

Test #3:

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

input:

4

output:

aaaaaaaa
aaaabaaa
baaabaaa
baaabbaa

result:

ok good solution

Test #4:

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

input:

6

output:

aaaaaaaa
aaaabaaa
baaabaaa
baaabbaa
bbaabbaa
bbaaabaa

result:

ok good solution

Test #5:

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

input:

7

output:

aaaaaaaa
aaaabaaa
baaabaaa
baaabbaa
bbaabbaa
bbaaabaa
abaaabaa

result:

ok good solution

Test #6:

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

input:

8

output:

aaaaaaaa
aaaabaaa
baaabaaa
baaabbaa
bbaabbaa
bbaaabaa
abaaabaa
abaaabba

result:

ok good solution

Test #7:

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

input:

9

output:

aaaaaaaa
aaaabaaa
baaabaaa
baaabbaa
bbaabbaa
bbaaabaa
abaaabaa
abaaabba
abbaabba

result:

ok good solution

Test #8:

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

input:

10

output:

aaaaaaaa
aaaabaaa
baaabaaa
baaabbaa
bbaabbaa
bbaaabaa
abaaabaa
abaaabba
abbaabba
abbaaaba

result:

ok good solution

Test #9:

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

input:

64

output:

aaaaaaaa
aaaabaaa
baaabaaa
baaabbaa
bbaabbaa
bbaaabaa
abaaabaa
abaaabba
abbaabba
abbaaaba
aabaaaba
aabababa
babababa
bababbba
bbbabbba
bbbabbbb
bbbbbbbb
bbbbabbb
abbbabbb
abbbaabb
aabbaabb
aabbaaab
aaabaaab
aaabbaab
baabbaab
baabbbab
bbabbbab
bbababab
abababab
ababcbab
cbabcbab
cbabcaab
caabcaab
caa...

result:

ok good solution

Test #10:

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

input:

51

output:

aaaaaaaa
aaaabaaa
baaabaaa
baaabbaa
bbaabbaa
bbaaabaa
abaaabaa
abaaabba
abbaabba
abbaaaba
aabaaaba
aabababa
babababa
bababbba
bbbabbba
bbbabbbb
bbbbbbbb
bbbbabbb
abbbabbb
abbbaabb
aabbaabb
aabbaaab
aaabaaab
aaabbaab
baabbaab
baabbbab
bbabbbab
bbababab
abababab
ababcbab
cbabcbab
cbabcaab
caabcaab
caa...

result:

ok good solution

Test #11:

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

input:

97

output:

aaaaaaaa
aaaabaaa
baaabaaa
baaabbaa
bbaabbaa
bbaaabaa
abaaabaa
abaaabba
abbaabba
abbaaaba
aabaaaba
aabababa
babababa
bababbba
bbbabbba
bbbabbbb
bbbbbbbb
bbbbabbb
abbbabbb
abbbaabb
aabbaabb
aabbaaab
aaabaaab
aaabbaab
baabbaab
baabbbab
bbabbbab
bbababab
abababab
ababcbab
cbabcbab
cbabcaab
caabcaab
caa...

result:

ok good solution

Test #12:

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

input:

100

output:

aaaaaaaa
aaaabaaa
baaabaaa
baaabbaa
bbaabbaa
bbaaabaa
abaaabaa
abaaabba
abbaabba
abbaaaba
aabaaaba
aabababa
babababa
bababbba
bbbabbba
bbbabbbb
bbbbbbbb
bbbbabbb
abbbabbb
abbbaabb
aabbaabb
aabbaaab
aaabaaab
aaabbaab
baabbaab
baabbbab
bbabbbab
bbababab
abababab
ababcbab
cbabcbab
cbabcaab
caabcaab
caa...

result:

ok good solution

Test #13:

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

input:

1000

output:

aaaaaaaa
aaaabaaa
baaabaaa
baaabbaa
bbaabbaa
bbaaabaa
abaaabaa
abaaabba
abbaabba
abbaaaba
aabaaaba
aabababa
babababa
bababbba
bbbabbba
bbbabbbb
bbbbbbbb
bbbbabbb
abbbabbb
abbbaabb
aabbaabb
aabbaaab
aaabaaab
aaabbaab
baabbaab
baabbbab
bbabbbab
bbababab
abababab
ababcbab
cbabcbab
cbabcaab
caabcaab
caa...

result:

ok good solution

Test #14:

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

input:

1001

output:

aaaaaaaa
aaaabaaa
baaabaaa
baaabbaa
bbaabbaa
bbaaabaa
abaaabaa
abaaabba
abbaabba
abbaaaba
aabaaaba
aabababa
babababa
bababbba
bbbabbba
bbbabbbb
bbbbbbbb
bbbbabbb
abbbabbb
abbbaabb
aabbaabb
aabbaaab
aaabaaab
aaabbaab
baabbaab
baabbbab
bbabbbab
bbababab
abababab
ababcbab
cbabcbab
cbabcaab
caabcaab
caa...

result:

ok good solution

Test #15:

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

input:

1024

output:

aaaaaaaa
aaaabaaa
baaabaaa
baaabbaa
bbaabbaa
bbaaabaa
abaaabaa
abaaabba
abbaabba
abbaaaba
aabaaaba
aabababa
babababa
bababbba
bbbabbba
bbbabbbb
bbbbbbbb
bbbbabbb
abbbabbb
abbbaabb
aabbaabb
aabbaaab
aaabaaab
aaabbaab
baabbaab
baabbbab
bbabbbab
bbababab
abababab
ababcbab
cbabcbab
cbabcaab
caabcaab
caa...

result:

ok good solution

Test #16:

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

input:

1025

output:

aaaaaaaa
aaaabaaa
baaabaaa
baaabbaa
bbaabbaa
bbaaabaa
abaaabaa
abaaabba
abbaabba
abbaaaba
aabaaaba
aabababa
babababa
bababbba
bbbabbba
bbbabbbb
bbbbbbbb
bbbbabbb
abbbabbb
abbbaabb
aabbaabb
aabbaaab
aaabaaab
aaabbaab
baabbaab
baabbbab
bbabbbab
bbababab
abababab
ababcbab
cbabcbab
cbabcaab
caabcaab
caa...

result:

ok good solution

Test #17:

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

input:

5000

output:

aaaaaaaa
aaaabaaa
baaabaaa
baaabbaa
bbaabbaa
bbaaabaa
abaaabaa
abaaabba
abbaabba
abbaaaba
aabaaaba
aabababa
babababa
bababbba
bbbabbba
bbbabbbb
bbbbbbbb
bbbbabbb
abbbabbb
abbbaabb
aabbaabb
aabbaaab
aaabaaab
aaabbaab
baabbaab
baabbbab
bbabbbab
bbababab
abababab
ababcbab
cbabcbab
cbabcaab
caabcaab
caa...

result:

ok good solution

Test #18:

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

input:

4999

output:

aaaaaaaa
aaaabaaa
baaabaaa
baaabbaa
bbaabbaa
bbaaabaa
abaaabaa
abaaabba
abbaabba
abbaaaba
aabaaaba
aabababa
babababa
bababbba
bbbabbba
bbbabbbb
bbbbbbbb
bbbbabbb
abbbabbb
abbbaabb
aabbaabb
aabbaaab
aaabaaab
aaabbaab
baabbaab
baabbbab
bbabbbab
bbababab
abababab
ababcbab
cbabcbab
cbabcaab
caabcaab
caa...

result:

ok good solution

Test #19:

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

input:

4096

output:

aaaaaaaa
aaaabaaa
baaabaaa
baaabbaa
bbaabbaa
bbaaabaa
abaaabaa
abaaabba
abbaabba
abbaaaba
aabaaaba
aabababa
babababa
bababbba
bbbabbba
bbbabbbb
bbbbbbbb
bbbbabbb
abbbabbb
abbbaabb
aabbaabb
aabbaaab
aaabaaab
aaabbaab
baabbaab
baabbbab
bbabbbab
bbababab
abababab
ababcbab
cbabcbab
cbabcaab
caabcaab
caa...

result:

ok good solution

Test #20:

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

input:

4097

output:

aaaaaaaa
aaaabaaa
baaabaaa
baaabbaa
bbaabbaa
bbaaabaa
abaaabaa
abaaabba
abbaabba
abbaaaba
aabaaaba
aabababa
babababa
bababbba
bbbabbba
bbbabbbb
bbbbbbbb
bbbbabbb
abbbabbb
abbbaabb
aabbaabb
aabbaaab
aaabaaab
aaabbaab
baabbaab
baabbbab
bbabbbab
bbababab
abababab
ababcbab
cbabcbab
cbabcaab
caabcaab
caa...

result:

ok good solution

Test #21:

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

input:

4098

output:

aaaaaaaa
aaaabaaa
baaabaaa
baaabbaa
bbaabbaa
bbaaabaa
abaaabaa
abaaabba
abbaabba
abbaaaba
aabaaaba
aabababa
babababa
bababbba
bbbabbba
bbbabbbb
bbbbbbbb
bbbbabbb
abbbabbb
abbbaabb
aabbaabb
aabbaaab
aaabaaab
aaabbaab
baabbaab
baabbbab
bbabbbab
bbababab
abababab
ababcbab
cbabcbab
cbabcaab
caabcaab
caa...

result:

ok good solution

Test #22:

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

input:

3751

output:

aaaaaaaa
aaaabaaa
baaabaaa
baaabbaa
bbaabbaa
bbaaabaa
abaaabaa
abaaabba
abbaabba
abbaaaba
aabaaaba
aabababa
babababa
bababbba
bbbabbba
bbbabbbb
bbbbbbbb
bbbbabbb
abbbabbb
abbbaabb
aabbaabb
aabbaaab
aaabaaab
aaabbaab
baabbaab
baabbbab
bbabbbab
bbababab
abababab
ababcbab
cbabcbab
cbabcaab
caabcaab
caa...

result:

ok good solution