QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#64955 | #4237. Word Ladder | Sa3tElSefr# | AC ✓ | 422ms | 80428kb | C++20 | 1.3kb | 2022-11-26 00:19:30 | 2022-11-26 00:19:33 |
Judging History
answer
#pragma GCC optimize("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
const int N = 5005 + 9, mod = 998244353;
const ll OO = 1e9;
int n;
set<string> vis;
vector<string> v;
bool solve(string cur, int d) {
if (d == 5000) {
return true;
}
v.push_back(cur);
for (int i = 0; i < cur.size(); ++i) {
for (char j = 'a'; j <= 'z'; ++j) {
if (cur[i] != j) {
auto nxt = cur;
nxt[i] = j;
if (vis.find(nxt) == vis.end()) {
for (int k = 0; k < cur.size(); ++k) {
for (char l = 'a'; l <= 'z'; ++l) {
auto tmp = cur;
tmp[k] = l;
vis.insert(tmp);
}
}
return solve(nxt, d + 1);
}
}
}
}
return false;
}
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
vis.insert(string(10, 'a'));
solve(string(10, 'a'), 0);
cin >> n;
for (int i = 0; i < n; ++i) {
cout << v[i] << '\n';
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 384ms
memory: 80344kb
input:
5
output:
aaaaaaaaaa baaaaaaaaa bbaaaaaaaa cbaaaaaaaa ccaaaaaaaa
result:
ok good solution
Test #2:
score: 0
Accepted
time: 414ms
memory: 80256kb
input:
3
output:
aaaaaaaaaa baaaaaaaaa bbaaaaaaaa
result:
ok good solution
Test #3:
score: 0
Accepted
time: 391ms
memory: 80260kb
input:
4
output:
aaaaaaaaaa baaaaaaaaa bbaaaaaaaa cbaaaaaaaa
result:
ok good solution
Test #4:
score: 0
Accepted
time: 383ms
memory: 80344kb
input:
6
output:
aaaaaaaaaa baaaaaaaaa bbaaaaaaaa cbaaaaaaaa ccaaaaaaaa dcaaaaaaaa
result:
ok good solution
Test #5:
score: 0
Accepted
time: 374ms
memory: 80364kb
input:
7
output:
aaaaaaaaaa baaaaaaaaa bbaaaaaaaa cbaaaaaaaa ccaaaaaaaa dcaaaaaaaa ddaaaaaaaa
result:
ok good solution
Test #6:
score: 0
Accepted
time: 367ms
memory: 80324kb
input:
8
output:
aaaaaaaaaa baaaaaaaaa bbaaaaaaaa cbaaaaaaaa ccaaaaaaaa dcaaaaaaaa ddaaaaaaaa edaaaaaaaa
result:
ok good solution
Test #7:
score: 0
Accepted
time: 376ms
memory: 80344kb
input:
9
output:
aaaaaaaaaa baaaaaaaaa bbaaaaaaaa cbaaaaaaaa ccaaaaaaaa dcaaaaaaaa ddaaaaaaaa edaaaaaaaa eeaaaaaaaa
result:
ok good solution
Test #8:
score: 0
Accepted
time: 386ms
memory: 80276kb
input:
10
output:
aaaaaaaaaa baaaaaaaaa bbaaaaaaaa cbaaaaaaaa ccaaaaaaaa dcaaaaaaaa ddaaaaaaaa edaaaaaaaa eeaaaaaaaa feaaaaaaaa
result:
ok good solution
Test #9:
score: 0
Accepted
time: 369ms
memory: 80312kb
input:
64
output:
aaaaaaaaaa baaaaaaaaa bbaaaaaaaa cbaaaaaaaa ccaaaaaaaa dcaaaaaaaa ddaaaaaaaa edaaaaaaaa eeaaaaaaaa feaaaaaaaa ffaaaaaaaa gfaaaaaaaa ggaaaaaaaa hgaaaaaaaa hhaaaaaaaa ihaaaaaaaa iiaaaaaaaa jiaaaaaaaa jjaaaaaaaa kjaaaaaaaa kkaaaaaaaa lkaaaaaaaa llaaaaaaaa mlaaaaaaaa mmaaaaaaaa nmaaaaaaaa nnaaaaaaaa ona...
result:
ok good solution
Test #10:
score: 0
Accepted
time: 378ms
memory: 80352kb
input:
51
output:
aaaaaaaaaa baaaaaaaaa bbaaaaaaaa cbaaaaaaaa ccaaaaaaaa dcaaaaaaaa ddaaaaaaaa edaaaaaaaa eeaaaaaaaa feaaaaaaaa ffaaaaaaaa gfaaaaaaaa ggaaaaaaaa hgaaaaaaaa hhaaaaaaaa ihaaaaaaaa iiaaaaaaaa jiaaaaaaaa jjaaaaaaaa kjaaaaaaaa kkaaaaaaaa lkaaaaaaaa llaaaaaaaa mlaaaaaaaa mmaaaaaaaa nmaaaaaaaa nnaaaaaaaa ona...
result:
ok good solution
Test #11:
score: 0
Accepted
time: 393ms
memory: 80280kb
input:
97
output:
aaaaaaaaaa baaaaaaaaa bbaaaaaaaa cbaaaaaaaa ccaaaaaaaa dcaaaaaaaa ddaaaaaaaa edaaaaaaaa eeaaaaaaaa feaaaaaaaa ffaaaaaaaa gfaaaaaaaa ggaaaaaaaa hgaaaaaaaa hhaaaaaaaa ihaaaaaaaa iiaaaaaaaa jiaaaaaaaa jjaaaaaaaa kjaaaaaaaa kkaaaaaaaa lkaaaaaaaa llaaaaaaaa mlaaaaaaaa mmaaaaaaaa nmaaaaaaaa nnaaaaaaaa ona...
result:
ok good solution
Test #12:
score: 0
Accepted
time: 377ms
memory: 80320kb
input:
100
output:
aaaaaaaaaa baaaaaaaaa bbaaaaaaaa cbaaaaaaaa ccaaaaaaaa dcaaaaaaaa ddaaaaaaaa edaaaaaaaa eeaaaaaaaa feaaaaaaaa ffaaaaaaaa gfaaaaaaaa ggaaaaaaaa hgaaaaaaaa hhaaaaaaaa ihaaaaaaaa iiaaaaaaaa jiaaaaaaaa jjaaaaaaaa kjaaaaaaaa kkaaaaaaaa lkaaaaaaaa llaaaaaaaa mlaaaaaaaa mmaaaaaaaa nmaaaaaaaa nnaaaaaaaa ona...
result:
ok good solution
Test #13:
score: 0
Accepted
time: 382ms
memory: 80268kb
input:
1000
output:
aaaaaaaaaa baaaaaaaaa bbaaaaaaaa cbaaaaaaaa ccaaaaaaaa dcaaaaaaaa ddaaaaaaaa edaaaaaaaa eeaaaaaaaa feaaaaaaaa ffaaaaaaaa gfaaaaaaaa ggaaaaaaaa hgaaaaaaaa hhaaaaaaaa ihaaaaaaaa iiaaaaaaaa jiaaaaaaaa jjaaaaaaaa kjaaaaaaaa kkaaaaaaaa lkaaaaaaaa llaaaaaaaa mlaaaaaaaa mmaaaaaaaa nmaaaaaaaa nnaaaaaaaa ona...
result:
ok good solution
Test #14:
score: 0
Accepted
time: 384ms
memory: 80188kb
input:
1001
output:
aaaaaaaaaa baaaaaaaaa bbaaaaaaaa cbaaaaaaaa ccaaaaaaaa dcaaaaaaaa ddaaaaaaaa edaaaaaaaa eeaaaaaaaa feaaaaaaaa ffaaaaaaaa gfaaaaaaaa ggaaaaaaaa hgaaaaaaaa hhaaaaaaaa ihaaaaaaaa iiaaaaaaaa jiaaaaaaaa jjaaaaaaaa kjaaaaaaaa kkaaaaaaaa lkaaaaaaaa llaaaaaaaa mlaaaaaaaa mmaaaaaaaa nmaaaaaaaa nnaaaaaaaa ona...
result:
ok good solution
Test #15:
score: 0
Accepted
time: 386ms
memory: 80428kb
input:
1024
output:
aaaaaaaaaa baaaaaaaaa bbaaaaaaaa cbaaaaaaaa ccaaaaaaaa dcaaaaaaaa ddaaaaaaaa edaaaaaaaa eeaaaaaaaa feaaaaaaaa ffaaaaaaaa gfaaaaaaaa ggaaaaaaaa hgaaaaaaaa hhaaaaaaaa ihaaaaaaaa iiaaaaaaaa jiaaaaaaaa jjaaaaaaaa kjaaaaaaaa kkaaaaaaaa lkaaaaaaaa llaaaaaaaa mlaaaaaaaa mmaaaaaaaa nmaaaaaaaa nnaaaaaaaa ona...
result:
ok good solution
Test #16:
score: 0
Accepted
time: 372ms
memory: 80300kb
input:
1025
output:
aaaaaaaaaa baaaaaaaaa bbaaaaaaaa cbaaaaaaaa ccaaaaaaaa dcaaaaaaaa ddaaaaaaaa edaaaaaaaa eeaaaaaaaa feaaaaaaaa ffaaaaaaaa gfaaaaaaaa ggaaaaaaaa hgaaaaaaaa hhaaaaaaaa ihaaaaaaaa iiaaaaaaaa jiaaaaaaaa jjaaaaaaaa kjaaaaaaaa kkaaaaaaaa lkaaaaaaaa llaaaaaaaa mlaaaaaaaa mmaaaaaaaa nmaaaaaaaa nnaaaaaaaa ona...
result:
ok good solution
Test #17:
score: 0
Accepted
time: 386ms
memory: 80216kb
input:
5000
output:
aaaaaaaaaa baaaaaaaaa bbaaaaaaaa cbaaaaaaaa ccaaaaaaaa dcaaaaaaaa ddaaaaaaaa edaaaaaaaa eeaaaaaaaa feaaaaaaaa ffaaaaaaaa gfaaaaaaaa ggaaaaaaaa hgaaaaaaaa hhaaaaaaaa ihaaaaaaaa iiaaaaaaaa jiaaaaaaaa jjaaaaaaaa kjaaaaaaaa kkaaaaaaaa lkaaaaaaaa llaaaaaaaa mlaaaaaaaa mmaaaaaaaa nmaaaaaaaa nnaaaaaaaa ona...
result:
ok good solution
Test #18:
score: 0
Accepted
time: 392ms
memory: 80328kb
input:
4999
output:
aaaaaaaaaa baaaaaaaaa bbaaaaaaaa cbaaaaaaaa ccaaaaaaaa dcaaaaaaaa ddaaaaaaaa edaaaaaaaa eeaaaaaaaa feaaaaaaaa ffaaaaaaaa gfaaaaaaaa ggaaaaaaaa hgaaaaaaaa hhaaaaaaaa ihaaaaaaaa iiaaaaaaaa jiaaaaaaaa jjaaaaaaaa kjaaaaaaaa kkaaaaaaaa lkaaaaaaaa llaaaaaaaa mlaaaaaaaa mmaaaaaaaa nmaaaaaaaa nnaaaaaaaa ona...
result:
ok good solution
Test #19:
score: 0
Accepted
time: 389ms
memory: 80328kb
input:
4096
output:
aaaaaaaaaa baaaaaaaaa bbaaaaaaaa cbaaaaaaaa ccaaaaaaaa dcaaaaaaaa ddaaaaaaaa edaaaaaaaa eeaaaaaaaa feaaaaaaaa ffaaaaaaaa gfaaaaaaaa ggaaaaaaaa hgaaaaaaaa hhaaaaaaaa ihaaaaaaaa iiaaaaaaaa jiaaaaaaaa jjaaaaaaaa kjaaaaaaaa kkaaaaaaaa lkaaaaaaaa llaaaaaaaa mlaaaaaaaa mmaaaaaaaa nmaaaaaaaa nnaaaaaaaa ona...
result:
ok good solution
Test #20:
score: 0
Accepted
time: 390ms
memory: 80264kb
input:
4097
output:
aaaaaaaaaa baaaaaaaaa bbaaaaaaaa cbaaaaaaaa ccaaaaaaaa dcaaaaaaaa ddaaaaaaaa edaaaaaaaa eeaaaaaaaa feaaaaaaaa ffaaaaaaaa gfaaaaaaaa ggaaaaaaaa hgaaaaaaaa hhaaaaaaaa ihaaaaaaaa iiaaaaaaaa jiaaaaaaaa jjaaaaaaaa kjaaaaaaaa kkaaaaaaaa lkaaaaaaaa llaaaaaaaa mlaaaaaaaa mmaaaaaaaa nmaaaaaaaa nnaaaaaaaa ona...
result:
ok good solution
Test #21:
score: 0
Accepted
time: 422ms
memory: 80264kb
input:
4098
output:
aaaaaaaaaa baaaaaaaaa bbaaaaaaaa cbaaaaaaaa ccaaaaaaaa dcaaaaaaaa ddaaaaaaaa edaaaaaaaa eeaaaaaaaa feaaaaaaaa ffaaaaaaaa gfaaaaaaaa ggaaaaaaaa hgaaaaaaaa hhaaaaaaaa ihaaaaaaaa iiaaaaaaaa jiaaaaaaaa jjaaaaaaaa kjaaaaaaaa kkaaaaaaaa lkaaaaaaaa llaaaaaaaa mlaaaaaaaa mmaaaaaaaa nmaaaaaaaa nnaaaaaaaa ona...
result:
ok good solution
Test #22:
score: 0
Accepted
time: 367ms
memory: 80192kb
input:
3751
output:
aaaaaaaaaa baaaaaaaaa bbaaaaaaaa cbaaaaaaaa ccaaaaaaaa dcaaaaaaaa ddaaaaaaaa edaaaaaaaa eeaaaaaaaa feaaaaaaaa ffaaaaaaaa gfaaaaaaaa ggaaaaaaaa hgaaaaaaaa hhaaaaaaaa ihaaaaaaaa iiaaaaaaaa jiaaaaaaaa jjaaaaaaaa kjaaaaaaaa kkaaaaaaaa lkaaaaaaaa llaaaaaaaa mlaaaaaaaa mmaaaaaaaa nmaaaaaaaa nnaaaaaaaa ona...
result:
ok good solution