QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#781274 | #4237. Word Ladder | ucup-team2172# | AC ✓ | 80ms | 3860kb | C++23 | 1.3kb | 2024-11-25 15:29:10 | 2024-11-25 15:29:27 |
Judging History
answer
#include <bits/stdc++.h>
#define inf (0x7f7f7f7f)
#define Max(a, b) ((a) > (b) ? (a) : (b))
#define Min(a, b) ((a) < (b) ? (a) : (b))
typedef long long ll;
using namespace std;
template <class T>
inline void read(T &x){
int ch = 0, f = 0; x = 0;
for(; !isdigit(ch); ch = getchar()) if(ch == '-') f = 1;
for(; isdigit(ch); ch = getchar()) x = x * 10 + ch - 48;
if(f) x = -x;
}
int n;
const int N = 5005;
char a[N][15];
bool check(int i){
int dif = 0;
for(int k = 0; k < 10; k++) if(a[i - 1][k] != a[i][k]) dif++;
if(dif != 1) return false;
for(int j = 1; j < i - 1; j++){
int diff = 0;
for(int k = 0; k < 10; k++) if(a[i][k] != a[j][k]) diff++;
if(diff <= 1) return false;
}
return true;
}
int main(){
srand(time(NULL));
read(n);
for(int i = 0; i < 10; i++) a[1][i] = 'a' + rand() % 26;
for(int i = 2; i <= n; i++){
do{
for(int j = 0; j < 10; j++){
a[i][j] = a[i - 1][j];
}
int pos = rand() % 10;
a[i][pos] = 'a' + rand() % 26;
}while(!check(i));
}
for(int i = 1; i <= n; i++){
for(int j = 0; j < 10; j++) putchar(a[i][j]);
puts("");
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3760kb
input:
5
output:
zikrjjndrt zikrjqndrt ziksjqndrt ziksjqcdrt ziksjqcdmt
result:
ok good solution
Test #2:
score: 0
Accepted
time: 0ms
memory: 3860kb
input:
3
output:
zikrjjndrt zikrjqndrt ziksjqndrt
result:
ok good solution
Test #3:
score: 0
Accepted
time: 0ms
memory: 3588kb
input:
4
output:
zikrjjndrt zikrjqndrt ziksjqndrt ziksjqcdrt
result:
ok good solution
Test #4:
score: 0
Accepted
time: 0ms
memory: 3856kb
input:
6
output:
zikrjjndrt zikrjqndrt ziksjqndrt ziksjqcdrt ziksjqcdmt ziknjqcdmt
result:
ok good solution
Test #5:
score: 0
Accepted
time: 0ms
memory: 3768kb
input:
7
output:
zikrjjndrt zikrjqndrt ziksjqndrt ziksjqcdrt ziksjqcdmt ziknjqcdmt ziknjqcdyt
result:
ok good solution
Test #6:
score: 0
Accepted
time: 0ms
memory: 3708kb
input:
8
output:
zikrjjndrt zikrjqndrt ziksjqndrt ziksjqcdrt ziksjqcdmt ziknjqcdmt ziknjqcdyt ziknjmcdyt
result:
ok good solution
Test #7:
score: 0
Accepted
time: 0ms
memory: 3712kb
input:
9
output:
zikrjjndrt zikrjqndrt ziksjqndrt ziksjqcdrt ziksjqcdmt ziknjqcdmt ziknjqcdyt ziknjmcdyt ziknjmcdyd
result:
ok good solution
Test #8:
score: 0
Accepted
time: 0ms
memory: 3760kb
input:
10
output:
zikrjjndrt zikrjqndrt ziksjqndrt ziksjqcdrt ziksjqcdmt ziknjqcdmt ziknjqcdyt ziknjmcdyt ziknjmcdyd qiknjmcdyd
result:
ok good solution
Test #9:
score: 0
Accepted
time: 0ms
memory: 3760kb
input:
64
output:
zikrjjndrt zikrjqndrt ziksjqndrt ziksjqcdrt ziksjqcdmt ziknjqcdmt ziknjqcdyt ziknjmcdyt ziknjmcdyd qiknjmcdyd qiknjmcdym qiknjmcnym qiknjmcnyk qisnjmcnyk pisnjmcnyk ptsnjmcnyk ptsnjmcnyf ptstjmcnyf ptstjrcnyf ptstjrcnyo ptstjrhnyo ptstjrhfyo ptstjwhfyo ptftjwhfyo ptftjwhfyn poftjwhfyn poftywhfyn pof...
result:
ok good solution
Test #10:
score: 0
Accepted
time: 0ms
memory: 3708kb
input:
51
output:
zikrjjndrt zikrjqndrt ziksjqndrt ziksjqcdrt ziksjqcdmt ziknjqcdmt ziknjqcdyt ziknjmcdyt ziknjmcdyd qiknjmcdyd qiknjmcdym qiknjmcnym qiknjmcnyk qisnjmcnyk pisnjmcnyk ptsnjmcnyk ptsnjmcnyf ptstjmcnyf ptstjrcnyf ptstjrcnyo ptstjrhnyo ptstjrhfyo ptstjwhfyo ptftjwhfyo ptftjwhfyn poftjwhfyn poftywhfyn pof...
result:
ok good solution
Test #11:
score: 0
Accepted
time: 0ms
memory: 3836kb
input:
97
output:
zikrjjndrt zikrjqndrt ziksjqndrt ziksjqcdrt ziksjqcdmt ziknjqcdmt ziknjqcdyt ziknjmcdyt ziknjmcdyd qiknjmcdyd qiknjmcdym qiknjmcnym qiknjmcnyk qisnjmcnyk pisnjmcnyk ptsnjmcnyk ptsnjmcnyf ptstjmcnyf ptstjrcnyf ptstjrcnyo ptstjrhnyo ptstjrhfyo ptstjwhfyo ptftjwhfyo ptftjwhfyn poftjwhfyn poftywhfyn pof...
result:
ok good solution
Test #12:
score: 0
Accepted
time: 0ms
memory: 3624kb
input:
100
output:
zikrjjndrt zikrjqndrt ziksjqndrt ziksjqcdrt ziksjqcdmt ziknjqcdmt ziknjqcdyt ziknjmcdyt ziknjmcdyd qiknjmcdyd qiknjmcdym qiknjmcnym qiknjmcnyk qisnjmcnyk pisnjmcnyk ptsnjmcnyk ptsnjmcnyf ptstjmcnyf ptstjrcnyf ptstjrcnyo ptstjrhnyo ptstjrhfyo ptstjwhfyo ptftjwhfyo ptftjwhfyn poftjwhfyn poftywhfyn pof...
result:
ok good solution
Test #13:
score: 0
Accepted
time: 4ms
memory: 3796kb
input:
1000
output:
zikrjjndrt zikrjqndrt ziksjqndrt ziksjqcdrt ziksjqcdmt ziknjqcdmt ziknjqcdyt ziknjmcdyt ziknjmcdyd qiknjmcdyd qiknjmcdym qiknjmcnym qiknjmcnyk qisnjmcnyk pisnjmcnyk ptsnjmcnyk ptsnjmcnyf ptstjmcnyf ptstjrcnyf ptstjrcnyo ptstjrhnyo ptstjrhfyo ptstjwhfyo ptftjwhfyo ptftjwhfyn poftjwhfyn poftywhfyn pof...
result:
ok good solution
Test #14:
score: 0
Accepted
time: 4ms
memory: 3848kb
input:
1001
output:
zikrjjndrt zikrjqndrt ziksjqndrt ziksjqcdrt ziksjqcdmt ziknjqcdmt ziknjqcdyt ziknjmcdyt ziknjmcdyd qiknjmcdyd qiknjmcdym qiknjmcnym qiknjmcnyk qisnjmcnyk pisnjmcnyk ptsnjmcnyk ptsnjmcnyf ptstjmcnyf ptstjrcnyf ptstjrcnyo ptstjrhnyo ptstjrhfyo ptstjwhfyo ptftjwhfyo ptftjwhfyn poftjwhfyn poftywhfyn pof...
result:
ok good solution
Test #15:
score: 0
Accepted
time: 4ms
memory: 3720kb
input:
1024
output:
zikrjjndrt zikrjqndrt ziksjqndrt ziksjqcdrt ziksjqcdmt ziknjqcdmt ziknjqcdyt ziknjmcdyt ziknjmcdyd qiknjmcdyd qiknjmcdym qiknjmcnym qiknjmcnyk qisnjmcnyk pisnjmcnyk ptsnjmcnyk ptsnjmcnyf ptstjmcnyf ptstjrcnyf ptstjrcnyo ptstjrhnyo ptstjrhfyo ptstjwhfyo ptftjwhfyo ptftjwhfyn poftjwhfyn poftywhfyn pof...
result:
ok good solution
Test #16:
score: 0
Accepted
time: 4ms
memory: 3800kb
input:
1025
output:
zikrjjndrt zikrjqndrt ziksjqndrt ziksjqcdrt ziksjqcdmt ziknjqcdmt ziknjqcdyt ziknjmcdyt ziknjmcdyd qiknjmcdyd qiknjmcdym qiknjmcnym qiknjmcnyk qisnjmcnyk pisnjmcnyk ptsnjmcnyk ptsnjmcnyf ptstjmcnyf ptstjrcnyf ptstjrcnyo ptstjrhnyo ptstjrhfyo ptstjwhfyo ptftjwhfyo ptftjwhfyn poftjwhfyn poftywhfyn pof...
result:
ok good solution
Test #17:
score: 0
Accepted
time: 80ms
memory: 3828kb
input:
5000
output:
zikrjjndrt zikrjqndrt ziksjqndrt ziksjqcdrt ziksjqcdmt ziknjqcdmt ziknjqcdyt ziknjmcdyt ziknjmcdyd qiknjmcdyd qiknjmcdym qiknjmcnym qiknjmcnyk qisnjmcnyk pisnjmcnyk ptsnjmcnyk ptsnjmcnyf ptstjmcnyf ptstjrcnyf ptstjrcnyo ptstjrhnyo ptstjrhfyo ptstjwhfyo ptftjwhfyo ptftjwhfyn poftjwhfyn poftywhfyn pof...
result:
ok good solution
Test #18:
score: 0
Accepted
time: 79ms
memory: 3832kb
input:
4999
output:
zikrjjndrt zikrjqndrt ziksjqndrt ziksjqcdrt ziksjqcdmt ziknjqcdmt ziknjqcdyt ziknjmcdyt ziknjmcdyd qiknjmcdyd qiknjmcdym qiknjmcnym qiknjmcnyk qisnjmcnyk pisnjmcnyk ptsnjmcnyk ptsnjmcnyf ptstjmcnyf ptstjrcnyf ptstjrcnyo ptstjrhnyo ptstjrhfyo ptstjwhfyo ptftjwhfyo ptftjwhfyn poftjwhfyn poftywhfyn pof...
result:
ok good solution
Test #19:
score: 0
Accepted
time: 53ms
memory: 3848kb
input:
4096
output:
owtxcndhgn owtfcndhgn owtfcndhge oxtfcndhge oxtscndhge oxtscndhxe oxtsbndhxe oxosbndhxe oxoibndhxe nxoibndhxe nxoixndhxe nxoixndvxe nxoixndvxo yxoixndvxo yxoixxdvxo yxoixxdvxj yxoixwdvxj yxoixwdmxj yxoixkdmxj yxoixkdmxc yxoixkjmxc yxoixkjmsc yxoixojmsc yxoixotmsc yxoixothsc yyoixothsc oyoixothsc oyo...
result:
ok good solution
Test #20:
score: 0
Accepted
time: 54ms
memory: 3700kb
input:
4097
output:
owtxcndhgn owtfcndhgn owtfcndhge oxtfcndhge oxtscndhge oxtscndhxe oxtsbndhxe oxosbndhxe oxoibndhxe nxoibndhxe nxoixndhxe nxoixndvxe nxoixndvxo yxoixndvxo yxoixxdvxo yxoixxdvxj yxoixwdvxj yxoixwdmxj yxoixkdmxj yxoixkdmxc yxoixkjmxc yxoixkjmsc yxoixojmsc yxoixotmsc yxoixothsc yyoixothsc oyoixothsc oyo...
result:
ok good solution
Test #21:
score: 0
Accepted
time: 53ms
memory: 3768kb
input:
4098
output:
owtxcndhgn owtfcndhgn owtfcndhge oxtfcndhge oxtscndhge oxtscndhxe oxtsbndhxe oxosbndhxe oxoibndhxe nxoibndhxe nxoixndhxe nxoixndvxe nxoixndvxo yxoixndvxo yxoixxdvxo yxoixxdvxj yxoixwdvxj yxoixwdmxj yxoixkdmxj yxoixkdmxc yxoixkjmxc yxoixkjmsc yxoixojmsc yxoixotmsc yxoixothsc yyoixothsc oyoixothsc oyo...
result:
ok good solution
Test #22:
score: 0
Accepted
time: 45ms
memory: 3824kb
input:
3751
output:
owtxcndhgn owtfcndhgn owtfcndhge oxtfcndhge oxtscndhge oxtscndhxe oxtsbndhxe oxosbndhxe oxoibndhxe nxoibndhxe nxoixndhxe nxoixndvxe nxoixndvxo yxoixndvxo yxoixxdvxo yxoixxdvxj yxoixwdvxj yxoixwdmxj yxoixkdmxj yxoixkdmxc yxoixkjmxc yxoixkjmsc yxoixojmsc yxoixotmsc yxoixothsc yyoixothsc oyoixothsc oyo...
result:
ok good solution