QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#501007#855. A Very Different WordFavorGewAC ✓1ms6160kbC++20894b2024-08-02 10:35:142024-08-02 10:35:15

Judging History

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

  • [2024-08-02 10:35:15]
  • 评测
  • 测评结果:AC
  • 用时:1ms
  • 内存:6160kb
  • [2024-08-02 10:35:14]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
string s, t;
int n;
bool flag;
char Ans[25550];
char ch;
void dfs(int pos, bool a1, bool a2, bool a3) {
    if(pos == n) {
        if(a1 || a2) return;
        if(!a3) return; 
        for(int i = 0; i < n; ++ i) {
            cout << Ans[i];
        }
        cout << "\n";
        flag = 1;
        return;
    }
    char st = 'a', en = 'z';
    if(a1) st = s[pos];
    if(a2) en = t[pos];
    for(char i = st; i <= en; ++ i) {
        Ans[pos] = i;
        dfs(pos + 1, a1 & (i == st), a2 & (i == en), a3 | (i == ch));
        if(flag) return;
    }
}
void Do() {
    cin >> n >> ch;
    cin >> s >> t;
    flag = false;
    dfs(0, 1, 1, 0);
    if(flag) return;
    cout << "NO\n";
}
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int T; cin >> T;
    while(T --) {
        Do();
    }
}

详细

Test #1:

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

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: 3648kb

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
abcayaaaaaaaaa
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: 1ms
memory: 3588kb

input:

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

output:

NO
yadswtbucvyybqqbzelblcqjxodpsicgtjzagazrnqxycqhadpljbzlneduawfsfxxvoipdafjdpamgeydrjercplbvdbhieiofdgegkgxezghtwwhqzigfjgouvputfkmawngwgvgsknfkgupbwujaielpryeifgfukygdjxmvlkziruxbuxra
rumfusabgtvavyqvmw
lxnfntyxjpmtqnqubthagytoddtpqcxlexdtflwzyokizyrcqkpctbjewodyusiiepdvkmjouoajxwvapvtmatbnwbpsqq...

result:

ok OK!

Test #4:

score: 0
Accepted
time: 1ms
memory: 3648kb

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: 0ms
memory: 6160kb

input:

4
25000 h
ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff...

output:

NO
zxyyadswtbucvyybqqbzelblcqjxodpsicgtjzagazrnqxycqhadpljbzlneduawfsfxxvoipdafjdpamgeydrjercplbvdbhieiofdgegkgxezghtwwhqzigfjgouvputfkmawngwgvgsknfkgupbwujaielpryeiffukygdjxmvlkziruxbuxqzguhcevzputscajbughtgvtaevoywqbvkmgvtmitzclxnfntyxjpmtqnqubthagyoldfdqtcpsqwchxvlmenxfdstdfvlkwqzsygokkgimzsyprkc...

result:

ok OK!