QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#456353#855. A Very Different WordKevin5307#AC ✓1ms3616kbC++231.3kb2024-06-27 19:50:102024-06-27 19:50:10

Judging History

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

  • [2024-06-27 19:50:10]
  • 评测
  • 测评结果:AC
  • 用时:1ms
  • 内存:3616kb
  • [2024-06-27 19:50:10]
  • 提交

answer

//Author: Kevin
#include<bits/stdc++.h>
//#pragma GCC optimize("O2")
using namespace std;
#define ll long long
#define ull unsigned ll
#define pb emplace_back
#define mp make_pair
#define ALL(x) (x).begin(),(x).end()
#define rALL(x) (x).rbegin(),(x).rend()
#define srt(x) sort(ALL(x))
#define rev(x) reverse(ALL(x))
#define rsrt(x) sort(rALL(x))
#define sz(x) (int)(x.size())
#define inf 0x3f3f3f3f
#define pii pair<int,int>
#define lb(v,x) (int)(lower_bound(ALL(v),x)-v.begin())
#define ub(v,x) (int)(upper_bound(ALL(v),x)-v.begin())
#define uni(v) v.resize(unique(ALL(v))-v.begin())
#define longer __int128_t
void die(string S){puts(S.c_str());exit(0);}
void add(string &s)
{
	int p=sz(s)-1;
	s[p]++;
	while(p&&s[p]>'z')
	{
		s[p]='a';
		p--;
		s[p]++;
	}
}
void sub(string &s)
{
	int p=sz(s)-1;
	s[p]--;
	while(p&&s[p]<'a')
	{
		s[p]='z';
		p--;
		s[p]--;
	}
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int t;
	cin>>t;
	while(t--)
	{
		int n;
		char ch;
		cin>>n>>ch;
		string s,t;
		cin>>s>>t;
		add(s);
		bool fd=0;
		while(s<t)
		{
			bool ok=0;
			for(auto c:s)
				if(c==ch)
					ok=1;
			if(ok)
			{
				cout<<s<<'\n';
				fd=1;
				break;
			}
			add(s);
		}
		if(!fd)
			cout<<"NO\n";
	}
	return 0;
}

详细

Test #1:

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

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

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

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

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

input:

4
25000 h
ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff...

output:

NO
zxyyadswtbucvyybqqbzelblcqjxodpsicgtjzagazrnqxycqhadpljbzlneduawfsfxxvoipdafjdpamgeydrjercplbvdbhieiofdgegkgxezghtwwhqzigfjgouvputfkmawngwgvgsknfkgupbwujaielpryeiffukygdjxmvlkziruxbuxqzguhcevzputscajbughtgvtaevoywqbvkmgvtmitzclxnfntyxjpmtqnqubthagyoldfdqtcpsqwchxvlmenxfdstdfvlkwqzsygokkgimzsyprkc...

result:

ok OK!