QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#456957#855. A Very Different Wordgrass8cow#AC ✓6ms5740kbC++17751b2024-06-28 18:57:052024-06-28 18:57:05

Judging History

你现在查看的是最新测评结果

  • [2024-06-28 18:57:05]
  • 评测
  • 测评结果:AC
  • 用时:6ms
  • 内存:5740kb
  • [2024-06-28 18:57:05]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
char L[101000],R[101000],K[2],C,X[101000];
int n;
bool fla;
void dfs(int x,bool fl,bool fr,bool is){
    if(fla)return;
    if(x==n+1||(!fl&&!fr)){
        if(fl||fr)return;
        if(x<=n||is){
            fla=1;
            for(int i=x;i<=n;i++)X[i]=C;
            for(int i=1;i<=n;i++)printf("%c",X[i]);puts("");
        }
        return;
    }
    for(int i=(fl?(L[x]-'a'):0);i<=(fr?(R[x]-'a'):25);i++)
    X[x]='a'+i,
    dfs(x+1,fl&(L[x]==i+'a'),fr&(R[x]==i+'a'),is|(i+'a'==C));
}
void sol(){
    scanf("%d%s",&n,K);C=K[0];
    scanf("%s%s",L+1,R+1);fla=0;
    dfs(1,1,1,0);
    if(!fla)puts("NO");
}
int main(){
    int T;scanf("%d",&T);while(T--)sol();
    return 0;
}

详细

Test #1:

score: 100
Accepted
time: 0ms
memory: 3852kb

input:

4
10 m
christmasa
christmasx
6 m
spring
winter
21 a
ithinkthereforeisleep
ithinkthereforeithink
3 z
tcs
tcz

output:

christmasb
sprinm
ithinkthereforeislefa
NO

result:

ok OK!

Test #2:

score: 0
Accepted
time: 0ms
memory: 3836kb

input:

149
10 m
christmasa
christmasx
21 a
ithinkthereforeisleep
ithinkthereforeithink
3 z
tcs
tcz
6 m
spring
winter
8 b
aaaaaaaa
aaaaaaac
9 l
aaabbbccc
xxxyyyzzz
14 c
abcaxzzzzzzzzz
abcayyyyyyyyyy
10 a
christmasa
christmasx
16 x
abcabcxyyyyzlmnt
abcabcxyyyyzlmob
11 q
qwertyaaaau
qwertyaaaba
12 z
nomnomnom...

output:

christmasb
ithinkthereforeislefa
NO
sprinm
aaaaaaab
aaabbbccl
abcayacccccccc
christmasb
abcabcxyyyyzlmnu
qwertyaaaav
NO
NO
NO
NO
y
NO
x
r
v
t
u
x
p
y
k
k
p
w
o
r
f
s
y
f
y
p
NO
p
g
o
k
y
m
NO
t
v
r
w
n
o
e
i
o
l
x
q
i
q
o
u
c
NO
h
n
f
f
j
w
y
s
v
y
h
i
n
NO
t
s
l
v
m
v
u
r
m
j
t
v
t
h
k
q
x
h
t
x
f
...

result:

ok OK!

Test #3:

score: 0
Accepted
time: 2ms
memory: 3856kb

input:

308
16 r
pppppppppppppppp
pppppppppppppppq
183 h
yadswtbucvyybqqbzelblcqjxodpsicgtjzagazrnqxycqhadpljbzlneduawfsfxxvoipdafjdpamgeydrjercplbvdbhieiofdgegkgxezghtwwhqzigfjgouvputfkmawngwgvgsknfkgupbwujaielpryeifgfukygdjxmvlkziruxbuxqz
yadswtbucvyybqqbzelblcqjxodpsicgtjzagazrnqxycqhadpljbzlneduawfsfxxv...

output:

NO
yadswtbucvyybqqbzelblcqjxodpsicgtjzagazrnqxycqhadpljbzlneduawfsfxxvoipdafjdpamgeydrjercplbvdbhieiofdgegkgxezghtwwhqzigfjgouvputfkmawngwgvgsknfkgupbwujaielpryeifgfukygdjxmvlkziruxbuxrh
rumfusabgtvavyqvmw
lxnfntyxjpmtqnqubthagytoddtpqcxlexdtflwzyokizyrcqkpctbjewodyusiiepdvkmjouoajxwvapvtmatbnwbpsqq...

result:

ok OK!

Test #4:

score: 0
Accepted
time: 2ms
memory: 3832kb

input:

2534
49 v
sttadpsqbqbrttbnnaudjbicnhslcmpgbfphuafaunknstbna
sttadpsqbqbrttbnnaudjbicnhslcmpgbfphuafaunknstbnf
31 y
jhbujlddqaseoestrlgmcaehcmakfdc
jhbujlddqaseoestrlgmcaehcmakfdt
19 w
dobmjbrdafhdglecfdf
dobmjbrdafhdglecfdi
45 v
dufgpssgnuhfehflqrmqpeijaskfsfrfpileifqmbsqia
dufgpssgnuhfehflqrmqpeija...

output:

NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
...

result:

ok OK!

Test #5:

score: 0
Accepted
time: 6ms
memory: 5740kb

input:

4
25000 h
ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff...

output:

NO
zxyyadswtbucvyybqqbzelblcqjxodpsicgtjzagazrnqxycqhadpljbzlneduawfsfxxvoipdafjdpamgeydrjercplbvdbhieiofdgegkgxezghtwwhqzigfjgouvputfkmawngwgvgsknfkgupbwujaielpryeiffukygdjxmvlkziruxbuxqzguhcevzputscajbughtgvtaevoywqbvkmgvtmitzclxnfntyxjpmtqnqubthagyoldfdqtcpsqwchxvlmenxfdstdfvlkwqzsygokkgimzsyprkc...

result:

ok OK!