QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#416743 | #4237. Word Ladder | frizzfrizz# | AC ✓ | 2ms | 4328kb | C++14 | 1.8kb | 2024-05-22 05:11:15 | 2024-05-22 05:11:15 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
#define A first
#define B second
#define SZ(x) (int)(x.size())
#define FR(i, a, b) for (int i = (a); i < (b); i++)
#define FOR(i, n) FR(i, 0, n)
int N;
vector<string> seq[10];
int editDis(string a, string b)
{
int ans = 0;
FOR(i, a.length())
ans += a[i] != b[i];
return ans;
}
int main()
{
cin >> N;
for (char i = 'a'; i <= 'y'; i++)
{
string temp1 = "", temp2 = "";
temp1 += i;
temp1 += i;
temp2 += i;
temp2 += i + 1;
seq[1].push_back(temp1);
seq[1].push_back(temp2);
}
seq[1].push_back("zz");
int until = 0;
FR(i, 2, 10)
{
for (char j = 'a'; j <= 'y'; j++)
{
if ((j - 'a') % 2 == 0)
{
FOR(k, SZ(seq[i - 1]))
{
string temp = "";
temp += j;
temp += j;
temp += seq[i - 1][k];
seq[i].push_back(temp);
}
}
else
{
for (int k = SZ(seq[i - 1]) - 1; k >= 0; k--)
{
string temp = "";
temp += j;
temp += j;
temp += seq[i - 1][k];
seq[i].push_back(temp);
}
}
string temp = seq[i][SZ(seq[i]) - 1];
temp[1] = j + 1;
seq[i].push_back(temp);
}
string temp = seq[i][SZ(seq[i]) - 1];
temp[0] = 'z';
seq[i].push_back(temp);
if (SZ(seq[i]) >= 5005)
{
until = i;
break;
}
}
FOR(i, N)
cout << seq[until][i] << "\n";
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 2ms
memory: 4168kb
input:
5
output:
aaaaaa aaaaab aaaabb aaaabc aaaacc
result:
ok good solution
Test #2:
score: 0
Accepted
time: 2ms
memory: 4328kb
input:
3
output:
aaaaaa aaaaab aaaabb
result:
ok good solution
Test #3:
score: 0
Accepted
time: 0ms
memory: 4276kb
input:
4
output:
aaaaaa aaaaab aaaabb aaaabc
result:
ok good solution
Test #4:
score: 0
Accepted
time: 2ms
memory: 4156kb
input:
6
output:
aaaaaa aaaaab aaaabb aaaabc aaaacc aaaacd
result:
ok good solution
Test #5:
score: 0
Accepted
time: 0ms
memory: 4236kb
input:
7
output:
aaaaaa aaaaab aaaabb aaaabc aaaacc aaaacd aaaadd
result:
ok good solution
Test #6:
score: 0
Accepted
time: 2ms
memory: 4228kb
input:
8
output:
aaaaaa aaaaab aaaabb aaaabc aaaacc aaaacd aaaadd aaaade
result:
ok good solution
Test #7:
score: 0
Accepted
time: 2ms
memory: 4180kb
input:
9
output:
aaaaaa aaaaab aaaabb aaaabc aaaacc aaaacd aaaadd aaaade aaaaee
result:
ok good solution
Test #8:
score: 0
Accepted
time: 0ms
memory: 4232kb
input:
10
output:
aaaaaa aaaaab aaaabb aaaabc aaaacc aaaacd aaaadd aaaade aaaaee aaaaef
result:
ok good solution
Test #9:
score: 0
Accepted
time: 2ms
memory: 4096kb
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 aaaavv...
result:
ok good solution
Test #10:
score: 0
Accepted
time: 0ms
memory: 4152kb
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 aaaavv...
result:
ok good solution
Test #11:
score: 0
Accepted
time: 2ms
memory: 4268kb
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 aaaavv...
result:
ok good solution
Test #12:
score: 0
Accepted
time: 2ms
memory: 4324kb
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 aaaavv...
result:
ok good solution
Test #13:
score: 0
Accepted
time: 2ms
memory: 4180kb
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 aaaavv...
result:
ok good solution
Test #14:
score: 0
Accepted
time: 2ms
memory: 4164kb
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 aaaavv...
result:
ok good solution
Test #15:
score: 0
Accepted
time: 2ms
memory: 4228kb
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 aaaavv...
result:
ok good solution
Test #16:
score: 0
Accepted
time: 2ms
memory: 4156kb
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 aaaavv...
result:
ok good solution
Test #17:
score: 0
Accepted
time: 2ms
memory: 4220kb
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 aaaavv...
result:
ok good solution
Test #18:
score: 0
Accepted
time: 2ms
memory: 4100kb
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 aaaavv...
result:
ok good solution
Test #19:
score: 0
Accepted
time: 2ms
memory: 4168kb
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 aaaavv...
result:
ok good solution
Test #20:
score: 0
Accepted
time: 2ms
memory: 4124kb
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 aaaavv...
result:
ok good solution
Test #21:
score: 0
Accepted
time: 0ms
memory: 4236kb
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 aaaavv...
result:
ok good solution
Test #22:
score: 0
Accepted
time: 2ms
memory: 4324kb
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 aaaavv...
result:
ok good solution