QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#416738 | #4237. Word Ladder | Lspeed# | AC ✓ | 2ms | 3880kb | C++14 | 3.0kb | 2024-05-22 04:58:17 | 2024-05-22 04:58:17 |
Judging History
answer
#include <iostream> // Input/output stream objects
#include <fstream> // File stream objects
#include <sstream> // String stream objects
#include <iomanip> // Input/output manipulators
#include <string> // String class and functions
#include <vector> // Dynamic array
#include <list> // Doubly linked list
#include <set> // Set container
#include <map> // Map container
#include <queue> // Queue container
#include <stack> // Stack container
#include <algorithm> // Algorithms on sequences (e.g., sort, find)
#include <cmath> // Mathematical functions
#include <climits> // LLONG_MAX, LLONG_MIN
#include <ctime> // Date and time functions
#include <cstdlib> // General purpose functions (e.g., memory management)
#include <cstring> // C-style string functions
#include <cctype> // Character classification functions
#include <cassert> // Assert function for debugging
#include <exception> // Standard exceptions
#include <functional> // Function objects
#include <iterator> // Iterator classes
#include <limits> // Numeric limits
#include <locale> // Localization and internationalization
#include <numeric> // Numeric operations (e.g., accumulate)
#include <random> // Random number generators
#include <stdexcept> // Standard exception classes
#include <typeinfo> // Runtime type information
#include <utility> // Utility components (e.g., std::pair)
#include <bitset>
using namespace std;
#define FOR(i, a, b) for(int i = a; i < (b); i++)
#define FORE(i, a, b) for(int i = a; i <= (b); i++)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
#define x first
#define y second
#define mp make_pair
#define PI 3.141592653
#define compress(coord) sort(all(coord)), coord.resize(unique(all(coord)) - coord.begin())
const double eps = 1e-9; // x < eps (x <= 0) x < -eps (x < 0)
const ll inf = LLONG_MAX;
int n, curcol = 1, add = 1;
vector<string> block;
vi idx(5);
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cin >> n;
FOR (i, 0, 26) {
string temp = "";
temp.push_back('a'+i);
temp.push_back('a'+i);
block.push_back(temp);
temp.pop_back();
temp.push_back('a'+i+1);
block.push_back(temp);
}
block.pop_back(); // take z{ out
int cnt = 0;
while (true) {
for (int id: idx) cout << block[id];
cout << endl;
cnt++;
if (cnt == n) break;
idx[0] += add;
if (idx[0] == sz(block) || idx[0] == -1) {
if (idx[0] == sz(block)) idx[0] = sz(block) - 1, add = -1;
else idx[0] = 0, add = 1;
if (idx[curcol] == sz(block) - 1) curcol++;
idx[curcol]++;
for (int id: idx) cout << block[id];
cout << endl;
cnt++;
if (cnt == n) break;
idx[curcol]++;
}
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3640kb
input:
5
output:
aaaaaaaaaa abaaaaaaaa bbaaaaaaaa bcaaaaaaaa ccaaaaaaaa
result:
ok good solution
Test #2:
score: 0
Accepted
time: 0ms
memory: 3580kb
input:
3
output:
aaaaaaaaaa abaaaaaaaa bbaaaaaaaa
result:
ok good solution
Test #3:
score: 0
Accepted
time: 0ms
memory: 3584kb
input:
4
output:
aaaaaaaaaa abaaaaaaaa bbaaaaaaaa bcaaaaaaaa
result:
ok good solution
Test #4:
score: 0
Accepted
time: 0ms
memory: 3836kb
input:
6
output:
aaaaaaaaaa abaaaaaaaa bbaaaaaaaa bcaaaaaaaa ccaaaaaaaa cdaaaaaaaa
result:
ok good solution
Test #5:
score: 0
Accepted
time: 0ms
memory: 3868kb
input:
7
output:
aaaaaaaaaa abaaaaaaaa bbaaaaaaaa bcaaaaaaaa ccaaaaaaaa cdaaaaaaaa ddaaaaaaaa
result:
ok good solution
Test #6:
score: 0
Accepted
time: 0ms
memory: 3868kb
input:
8
output:
aaaaaaaaaa abaaaaaaaa bbaaaaaaaa bcaaaaaaaa ccaaaaaaaa cdaaaaaaaa ddaaaaaaaa deaaaaaaaa
result:
ok good solution
Test #7:
score: 0
Accepted
time: 0ms
memory: 3636kb
input:
9
output:
aaaaaaaaaa abaaaaaaaa bbaaaaaaaa bcaaaaaaaa ccaaaaaaaa cdaaaaaaaa ddaaaaaaaa deaaaaaaaa eeaaaaaaaa
result:
ok good solution
Test #8:
score: 0
Accepted
time: 0ms
memory: 3836kb
input:
10
output:
aaaaaaaaaa abaaaaaaaa bbaaaaaaaa bcaaaaaaaa ccaaaaaaaa cdaaaaaaaa ddaaaaaaaa deaaaaaaaa eeaaaaaaaa efaaaaaaaa
result:
ok good solution
Test #9:
score: 0
Accepted
time: 0ms
memory: 3644kb
input:
64
output:
aaaaaaaaaa abaaaaaaaa bbaaaaaaaa bcaaaaaaaa ccaaaaaaaa cdaaaaaaaa ddaaaaaaaa deaaaaaaaa eeaaaaaaaa efaaaaaaaa ffaaaaaaaa fgaaaaaaaa ggaaaaaaaa ghaaaaaaaa hhaaaaaaaa hiaaaaaaaa iiaaaaaaaa ijaaaaaaaa jjaaaaaaaa jkaaaaaaaa kkaaaaaaaa klaaaaaaaa llaaaaaaaa lmaaaaaaaa mmaaaaaaaa mnaaaaaaaa nnaaaaaaaa noa...
result:
ok good solution
Test #10:
score: 0
Accepted
time: 0ms
memory: 3676kb
input:
51
output:
aaaaaaaaaa abaaaaaaaa bbaaaaaaaa bcaaaaaaaa ccaaaaaaaa cdaaaaaaaa ddaaaaaaaa deaaaaaaaa eeaaaaaaaa efaaaaaaaa ffaaaaaaaa fgaaaaaaaa ggaaaaaaaa ghaaaaaaaa hhaaaaaaaa hiaaaaaaaa iiaaaaaaaa ijaaaaaaaa jjaaaaaaaa jkaaaaaaaa kkaaaaaaaa klaaaaaaaa llaaaaaaaa lmaaaaaaaa mmaaaaaaaa mnaaaaaaaa nnaaaaaaaa noa...
result:
ok good solution
Test #11:
score: 0
Accepted
time: 0ms
memory: 3676kb
input:
97
output:
aaaaaaaaaa abaaaaaaaa bbaaaaaaaa bcaaaaaaaa ccaaaaaaaa cdaaaaaaaa ddaaaaaaaa deaaaaaaaa eeaaaaaaaa efaaaaaaaa ffaaaaaaaa fgaaaaaaaa ggaaaaaaaa ghaaaaaaaa hhaaaaaaaa hiaaaaaaaa iiaaaaaaaa ijaaaaaaaa jjaaaaaaaa jkaaaaaaaa kkaaaaaaaa klaaaaaaaa llaaaaaaaa lmaaaaaaaa mmaaaaaaaa mnaaaaaaaa nnaaaaaaaa noa...
result:
ok good solution
Test #12:
score: 0
Accepted
time: 0ms
memory: 3844kb
input:
100
output:
aaaaaaaaaa abaaaaaaaa bbaaaaaaaa bcaaaaaaaa ccaaaaaaaa cdaaaaaaaa ddaaaaaaaa deaaaaaaaa eeaaaaaaaa efaaaaaaaa ffaaaaaaaa fgaaaaaaaa ggaaaaaaaa ghaaaaaaaa hhaaaaaaaa hiaaaaaaaa iiaaaaaaaa ijaaaaaaaa jjaaaaaaaa jkaaaaaaaa kkaaaaaaaa klaaaaaaaa llaaaaaaaa lmaaaaaaaa mmaaaaaaaa mnaaaaaaaa nnaaaaaaaa noa...
result:
ok good solution
Test #13:
score: 0
Accepted
time: 1ms
memory: 3636kb
input:
1000
output:
aaaaaaaaaa abaaaaaaaa bbaaaaaaaa bcaaaaaaaa ccaaaaaaaa cdaaaaaaaa ddaaaaaaaa deaaaaaaaa eeaaaaaaaa efaaaaaaaa ffaaaaaaaa fgaaaaaaaa ggaaaaaaaa ghaaaaaaaa hhaaaaaaaa hiaaaaaaaa iiaaaaaaaa ijaaaaaaaa jjaaaaaaaa jkaaaaaaaa kkaaaaaaaa klaaaaaaaa llaaaaaaaa lmaaaaaaaa mmaaaaaaaa mnaaaaaaaa nnaaaaaaaa noa...
result:
ok good solution
Test #14:
score: 0
Accepted
time: 0ms
memory: 3584kb
input:
1001
output:
aaaaaaaaaa abaaaaaaaa bbaaaaaaaa bcaaaaaaaa ccaaaaaaaa cdaaaaaaaa ddaaaaaaaa deaaaaaaaa eeaaaaaaaa efaaaaaaaa ffaaaaaaaa fgaaaaaaaa ggaaaaaaaa ghaaaaaaaa hhaaaaaaaa hiaaaaaaaa iiaaaaaaaa ijaaaaaaaa jjaaaaaaaa jkaaaaaaaa kkaaaaaaaa klaaaaaaaa llaaaaaaaa lmaaaaaaaa mmaaaaaaaa mnaaaaaaaa nnaaaaaaaa noa...
result:
ok good solution
Test #15:
score: 0
Accepted
time: 2ms
memory: 3652kb
input:
1024
output:
aaaaaaaaaa abaaaaaaaa bbaaaaaaaa bcaaaaaaaa ccaaaaaaaa cdaaaaaaaa ddaaaaaaaa deaaaaaaaa eeaaaaaaaa efaaaaaaaa ffaaaaaaaa fgaaaaaaaa ggaaaaaaaa ghaaaaaaaa hhaaaaaaaa hiaaaaaaaa iiaaaaaaaa ijaaaaaaaa jjaaaaaaaa jkaaaaaaaa kkaaaaaaaa klaaaaaaaa llaaaaaaaa lmaaaaaaaa mmaaaaaaaa mnaaaaaaaa nnaaaaaaaa noa...
result:
ok good solution
Test #16:
score: 0
Accepted
time: 2ms
memory: 3840kb
input:
1025
output:
aaaaaaaaaa abaaaaaaaa bbaaaaaaaa bcaaaaaaaa ccaaaaaaaa cdaaaaaaaa ddaaaaaaaa deaaaaaaaa eeaaaaaaaa efaaaaaaaa ffaaaaaaaa fgaaaaaaaa ggaaaaaaaa ghaaaaaaaa hhaaaaaaaa hiaaaaaaaa iiaaaaaaaa ijaaaaaaaa jjaaaaaaaa jkaaaaaaaa kkaaaaaaaa klaaaaaaaa llaaaaaaaa lmaaaaaaaa mmaaaaaaaa mnaaaaaaaa nnaaaaaaaa noa...
result:
ok good solution
Test #17:
score: 0
Accepted
time: 0ms
memory: 3636kb
input:
5000
output:
aaaaaaaaaa abaaaaaaaa bbaaaaaaaa bcaaaaaaaa ccaaaaaaaa cdaaaaaaaa ddaaaaaaaa deaaaaaaaa eeaaaaaaaa efaaaaaaaa ffaaaaaaaa fgaaaaaaaa ggaaaaaaaa ghaaaaaaaa hhaaaaaaaa hiaaaaaaaa iiaaaaaaaa ijaaaaaaaa jjaaaaaaaa jkaaaaaaaa kkaaaaaaaa klaaaaaaaa llaaaaaaaa lmaaaaaaaa mmaaaaaaaa mnaaaaaaaa nnaaaaaaaa noa...
result:
ok good solution
Test #18:
score: 0
Accepted
time: 0ms
memory: 3876kb
input:
4999
output:
aaaaaaaaaa abaaaaaaaa bbaaaaaaaa bcaaaaaaaa ccaaaaaaaa cdaaaaaaaa ddaaaaaaaa deaaaaaaaa eeaaaaaaaa efaaaaaaaa ffaaaaaaaa fgaaaaaaaa ggaaaaaaaa ghaaaaaaaa hhaaaaaaaa hiaaaaaaaa iiaaaaaaaa ijaaaaaaaa jjaaaaaaaa jkaaaaaaaa kkaaaaaaaa klaaaaaaaa llaaaaaaaa lmaaaaaaaa mmaaaaaaaa mnaaaaaaaa nnaaaaaaaa noa...
result:
ok good solution
Test #19:
score: 0
Accepted
time: 0ms
memory: 3588kb
input:
4096
output:
aaaaaaaaaa abaaaaaaaa bbaaaaaaaa bcaaaaaaaa ccaaaaaaaa cdaaaaaaaa ddaaaaaaaa deaaaaaaaa eeaaaaaaaa efaaaaaaaa ffaaaaaaaa fgaaaaaaaa ggaaaaaaaa ghaaaaaaaa hhaaaaaaaa hiaaaaaaaa iiaaaaaaaa ijaaaaaaaa jjaaaaaaaa jkaaaaaaaa kkaaaaaaaa klaaaaaaaa llaaaaaaaa lmaaaaaaaa mmaaaaaaaa mnaaaaaaaa nnaaaaaaaa noa...
result:
ok good solution
Test #20:
score: 0
Accepted
time: 0ms
memory: 3880kb
input:
4097
output:
aaaaaaaaaa abaaaaaaaa bbaaaaaaaa bcaaaaaaaa ccaaaaaaaa cdaaaaaaaa ddaaaaaaaa deaaaaaaaa eeaaaaaaaa efaaaaaaaa ffaaaaaaaa fgaaaaaaaa ggaaaaaaaa ghaaaaaaaa hhaaaaaaaa hiaaaaaaaa iiaaaaaaaa ijaaaaaaaa jjaaaaaaaa jkaaaaaaaa kkaaaaaaaa klaaaaaaaa llaaaaaaaa lmaaaaaaaa mmaaaaaaaa mnaaaaaaaa nnaaaaaaaa noa...
result:
ok good solution
Test #21:
score: 0
Accepted
time: 0ms
memory: 3876kb
input:
4098
output:
aaaaaaaaaa abaaaaaaaa bbaaaaaaaa bcaaaaaaaa ccaaaaaaaa cdaaaaaaaa ddaaaaaaaa deaaaaaaaa eeaaaaaaaa efaaaaaaaa ffaaaaaaaa fgaaaaaaaa ggaaaaaaaa ghaaaaaaaa hhaaaaaaaa hiaaaaaaaa iiaaaaaaaa ijaaaaaaaa jjaaaaaaaa jkaaaaaaaa kkaaaaaaaa klaaaaaaaa llaaaaaaaa lmaaaaaaaa mmaaaaaaaa mnaaaaaaaa nnaaaaaaaa noa...
result:
ok good solution
Test #22:
score: 0
Accepted
time: 0ms
memory: 3852kb
input:
3751
output:
aaaaaaaaaa abaaaaaaaa bbaaaaaaaa bcaaaaaaaa ccaaaaaaaa cdaaaaaaaa ddaaaaaaaa deaaaaaaaa eeaaaaaaaa efaaaaaaaa ffaaaaaaaa fgaaaaaaaa ggaaaaaaaa ghaaaaaaaa hhaaaaaaaa hiaaaaaaaa iiaaaaaaaa ijaaaaaaaa jjaaaaaaaa jkaaaaaaaa kkaaaaaaaa klaaaaaaaa llaaaaaaaa lmaaaaaaaa mmaaaaaaaa mnaaaaaaaa nnaaaaaaaa noa...
result:
ok good solution