QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#413052 | #4237. Word Ladder | DanielChang# | AC ✓ | 1ms | 3832kb | C++17 | 1021b | 2024-05-17 01:21:54 | 2024-05-17 01:21:55 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define endl '\n'
const int N = 5000;
vector<string> ans;
int main(){
ios::sync_with_stdio(false); cin.tie(0);
vector<int> a(4), dir(4, 1);
auto next = [&](){
for(int i=3; i>=0; i--){
int na = a[i] + dir[i];
if(na >= 0 && na < 26){
a[i] = na;
string s = ans.back();
s[2*i] = char('a' + na);
ans.push_back(s);
return;
}
dir[i] *= -1;
}
};
bool flag=0;
auto gen = [&](){
string s;
for(int d : a){
s += string(2, 'a' + d);
}
ans.push_back(s);
// for(int i=0; i<26; i++){
// char c = 'a' + i;
// if(flag) c = 'z' - i;
// s.push_back(c);
// ans.push_back(s);
// s.pop_back();
// }
flag ^= 1;
};
int n;
cin >> n;
while(ans.size() < n){
gen();
next();
}
while(ans.size() > n) ans.pop_back();
for(auto &d : ans){
cout << d << endl;
}
}
// gcc a.cpp -std=gnu++14 -o a.exe
// g++ a.cpp -g -O2 -std=gnu++14 -static -o a.exe
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3532kb
input:
5
output:
aaaaaaaa aaaaaaba aaaaaabb aaaaaacb aaaaaacc
result:
ok good solution
Test #2:
score: 0
Accepted
time: 0ms
memory: 3748kb
input:
3
output:
aaaaaaaa aaaaaaba aaaaaabb
result:
ok good solution
Test #3:
score: 0
Accepted
time: 0ms
memory: 3608kb
input:
4
output:
aaaaaaaa aaaaaaba aaaaaabb aaaaaacb
result:
ok good solution
Test #4:
score: 0
Accepted
time: 0ms
memory: 3592kb
input:
6
output:
aaaaaaaa aaaaaaba aaaaaabb aaaaaacb aaaaaacc aaaaaadc
result:
ok good solution
Test #5:
score: 0
Accepted
time: 0ms
memory: 3828kb
input:
7
output:
aaaaaaaa aaaaaaba aaaaaabb aaaaaacb aaaaaacc aaaaaadc aaaaaadd
result:
ok good solution
Test #6:
score: 0
Accepted
time: 0ms
memory: 3768kb
input:
8
output:
aaaaaaaa aaaaaaba aaaaaabb aaaaaacb aaaaaacc aaaaaadc aaaaaadd aaaaaaed
result:
ok good solution
Test #7:
score: 0
Accepted
time: 0ms
memory: 3576kb
input:
9
output:
aaaaaaaa aaaaaaba aaaaaabb aaaaaacb aaaaaacc aaaaaadc aaaaaadd aaaaaaed aaaaaaee
result:
ok good solution
Test #8:
score: 0
Accepted
time: 0ms
memory: 3808kb
input:
10
output:
aaaaaaaa aaaaaaba aaaaaabb aaaaaacb aaaaaacc aaaaaadc aaaaaadd aaaaaaed aaaaaaee aaaaaafe
result:
ok good solution
Test #9:
score: 0
Accepted
time: 0ms
memory: 3588kb
input:
64
output:
aaaaaaaa aaaaaaba aaaaaabb aaaaaacb aaaaaacc aaaaaadc aaaaaadd aaaaaaed aaaaaaee aaaaaafe aaaaaaff aaaaaagf aaaaaagg aaaaaahg aaaaaahh aaaaaaih aaaaaaii aaaaaaji aaaaaajj aaaaaakj aaaaaakk aaaaaalk aaaaaall aaaaaaml aaaaaamm aaaaaanm aaaaaann aaaaaaon aaaaaaoo aaaaaapo aaaaaapp aaaaaaqp aaaaaaqq aaa...
result:
ok good solution
Test #10:
score: 0
Accepted
time: 0ms
memory: 3832kb
input:
51
output:
aaaaaaaa aaaaaaba aaaaaabb aaaaaacb aaaaaacc aaaaaadc aaaaaadd aaaaaaed aaaaaaee aaaaaafe aaaaaaff aaaaaagf aaaaaagg aaaaaahg aaaaaahh aaaaaaih aaaaaaii aaaaaaji aaaaaajj aaaaaakj aaaaaakk aaaaaalk aaaaaall aaaaaaml aaaaaamm aaaaaanm aaaaaann aaaaaaon aaaaaaoo aaaaaapo aaaaaapp aaaaaaqp aaaaaaqq aaa...
result:
ok good solution
Test #11:
score: 0
Accepted
time: 0ms
memory: 3832kb
input:
97
output:
aaaaaaaa aaaaaaba aaaaaabb aaaaaacb aaaaaacc aaaaaadc aaaaaadd aaaaaaed aaaaaaee aaaaaafe aaaaaaff aaaaaagf aaaaaagg aaaaaahg aaaaaahh aaaaaaih aaaaaaii aaaaaaji aaaaaajj aaaaaakj aaaaaakk aaaaaalk aaaaaall aaaaaaml aaaaaamm aaaaaanm aaaaaann aaaaaaon aaaaaaoo aaaaaapo aaaaaapp aaaaaaqp aaaaaaqq aaa...
result:
ok good solution
Test #12:
score: 0
Accepted
time: 0ms
memory: 3492kb
input:
100
output:
aaaaaaaa aaaaaaba aaaaaabb aaaaaacb aaaaaacc aaaaaadc aaaaaadd aaaaaaed aaaaaaee aaaaaafe aaaaaaff aaaaaagf aaaaaagg aaaaaahg aaaaaahh aaaaaaih aaaaaaii aaaaaaji aaaaaajj aaaaaakj aaaaaakk aaaaaalk aaaaaall aaaaaaml aaaaaamm aaaaaanm aaaaaann aaaaaaon aaaaaaoo aaaaaapo aaaaaapp aaaaaaqp aaaaaaqq aaa...
result:
ok good solution
Test #13:
score: 0
Accepted
time: 1ms
memory: 3664kb
input:
1000
output:
aaaaaaaa aaaaaaba aaaaaabb aaaaaacb aaaaaacc aaaaaadc aaaaaadd aaaaaaed aaaaaaee aaaaaafe aaaaaaff aaaaaagf aaaaaagg aaaaaahg aaaaaahh aaaaaaih aaaaaaii aaaaaaji aaaaaajj aaaaaakj aaaaaakk aaaaaalk aaaaaall aaaaaaml aaaaaamm aaaaaanm aaaaaann aaaaaaon aaaaaaoo aaaaaapo aaaaaapp aaaaaaqp aaaaaaqq aaa...
result:
ok good solution
Test #14:
score: 0
Accepted
time: 0ms
memory: 3660kb
input:
1001
output:
aaaaaaaa aaaaaaba aaaaaabb aaaaaacb aaaaaacc aaaaaadc aaaaaadd aaaaaaed aaaaaaee aaaaaafe aaaaaaff aaaaaagf aaaaaagg aaaaaahg aaaaaahh aaaaaaih aaaaaaii aaaaaaji aaaaaajj aaaaaakj aaaaaakk aaaaaalk aaaaaall aaaaaaml aaaaaamm aaaaaanm aaaaaann aaaaaaon aaaaaaoo aaaaaapo aaaaaapp aaaaaaqp aaaaaaqq aaa...
result:
ok good solution
Test #15:
score: 0
Accepted
time: 0ms
memory: 3592kb
input:
1024
output:
aaaaaaaa aaaaaaba aaaaaabb aaaaaacb aaaaaacc aaaaaadc aaaaaadd aaaaaaed aaaaaaee aaaaaafe aaaaaaff aaaaaagf aaaaaagg aaaaaahg aaaaaahh aaaaaaih aaaaaaii aaaaaaji aaaaaajj aaaaaakj aaaaaakk aaaaaalk aaaaaall aaaaaaml aaaaaamm aaaaaanm aaaaaann aaaaaaon aaaaaaoo aaaaaapo aaaaaapp aaaaaaqp aaaaaaqq aaa...
result:
ok good solution
Test #16:
score: 0
Accepted
time: 0ms
memory: 3720kb
input:
1025
output:
aaaaaaaa aaaaaaba aaaaaabb aaaaaacb aaaaaacc aaaaaadc aaaaaadd aaaaaaed aaaaaaee aaaaaafe aaaaaaff aaaaaagf aaaaaagg aaaaaahg aaaaaahh aaaaaaih aaaaaaii aaaaaaji aaaaaajj aaaaaakj aaaaaakk aaaaaalk aaaaaall aaaaaaml aaaaaamm aaaaaanm aaaaaann aaaaaaon aaaaaaoo aaaaaapo aaaaaapp aaaaaaqp aaaaaaqq aaa...
result:
ok good solution
Test #17:
score: 0
Accepted
time: 1ms
memory: 3748kb
input:
5000
output:
aaaaaaaa aaaaaaba aaaaaabb aaaaaacb aaaaaacc aaaaaadc aaaaaadd aaaaaaed aaaaaaee aaaaaafe aaaaaaff aaaaaagf aaaaaagg aaaaaahg aaaaaahh aaaaaaih aaaaaaii aaaaaaji aaaaaajj aaaaaakj aaaaaakk aaaaaalk aaaaaall aaaaaaml aaaaaamm aaaaaanm aaaaaann aaaaaaon aaaaaaoo aaaaaapo aaaaaapp aaaaaaqp aaaaaaqq aaa...
result:
ok good solution
Test #18:
score: 0
Accepted
time: 0ms
memory: 3744kb
input:
4999
output:
aaaaaaaa aaaaaaba aaaaaabb aaaaaacb aaaaaacc aaaaaadc aaaaaadd aaaaaaed aaaaaaee aaaaaafe aaaaaaff aaaaaagf aaaaaagg aaaaaahg aaaaaahh aaaaaaih aaaaaaii aaaaaaji aaaaaajj aaaaaakj aaaaaakk aaaaaalk aaaaaall aaaaaaml aaaaaamm aaaaaanm aaaaaann aaaaaaon aaaaaaoo aaaaaapo aaaaaapp aaaaaaqp aaaaaaqq aaa...
result:
ok good solution
Test #19:
score: 0
Accepted
time: 1ms
memory: 3728kb
input:
4096
output:
aaaaaaaa aaaaaaba aaaaaabb aaaaaacb aaaaaacc aaaaaadc aaaaaadd aaaaaaed aaaaaaee aaaaaafe aaaaaaff aaaaaagf aaaaaagg aaaaaahg aaaaaahh aaaaaaih aaaaaaii aaaaaaji aaaaaajj aaaaaakj aaaaaakk aaaaaalk aaaaaall aaaaaaml aaaaaamm aaaaaanm aaaaaann aaaaaaon aaaaaaoo aaaaaapo aaaaaapp aaaaaaqp aaaaaaqq aaa...
result:
ok good solution
Test #20:
score: 0
Accepted
time: 1ms
memory: 3728kb
input:
4097
output:
aaaaaaaa aaaaaaba aaaaaabb aaaaaacb aaaaaacc aaaaaadc aaaaaadd aaaaaaed aaaaaaee aaaaaafe aaaaaaff aaaaaagf aaaaaagg aaaaaahg aaaaaahh aaaaaaih aaaaaaii aaaaaaji aaaaaajj aaaaaakj aaaaaakk aaaaaalk aaaaaall aaaaaaml aaaaaamm aaaaaanm aaaaaann aaaaaaon aaaaaaoo aaaaaapo aaaaaapp aaaaaaqp aaaaaaqq aaa...
result:
ok good solution
Test #21:
score: 0
Accepted
time: 1ms
memory: 3656kb
input:
4098
output:
aaaaaaaa aaaaaaba aaaaaabb aaaaaacb aaaaaacc aaaaaadc aaaaaadd aaaaaaed aaaaaaee aaaaaafe aaaaaaff aaaaaagf aaaaaagg aaaaaahg aaaaaahh aaaaaaih aaaaaaii aaaaaaji aaaaaajj aaaaaakj aaaaaakk aaaaaalk aaaaaall aaaaaaml aaaaaamm aaaaaanm aaaaaann aaaaaaon aaaaaaoo aaaaaapo aaaaaapp aaaaaaqp aaaaaaqq aaa...
result:
ok good solution
Test #22:
score: 0
Accepted
time: 1ms
memory: 3720kb
input:
3751
output:
aaaaaaaa aaaaaaba aaaaaabb aaaaaacb aaaaaacc aaaaaadc aaaaaadd aaaaaaed aaaaaaee aaaaaafe aaaaaaff aaaaaagf aaaaaagg aaaaaahg aaaaaahh aaaaaaih aaaaaaii aaaaaaji aaaaaajj aaaaaakj aaaaaakk aaaaaalk aaaaaall aaaaaaml aaaaaamm aaaaaanm aaaaaann aaaaaaon aaaaaaoo aaaaaapo aaaaaapp aaaaaaqp aaaaaaqq aaa...
result:
ok good solution