QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#121656 | #855. A Very Different Word | karuna# | AC ✓ | 2ms | 3504kb | C++14 | 1.3kb | 2023-07-08 16:35:11 | 2023-07-08 16:35:46 |
Judging History
answer
#include <bits/stdc++.h>
#define ff first
#define ss second
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int MAXN = 25000;
int TC, N;
char C;
string A, B;
int main() {
cin.tie(0); ios_base::sync_with_stdio(0);
cin>>TC;
while(TC--)
{
cin>>N>>C;
cin>>A>>B;
A="?"+A; B="?"+B;
A[N]+=1;
for(int i=N; i>=1; i--)
{
if(A[i]>'z') A[i]='a', A[i-1]++;
}
bool flag=true;
for(int i=1; i<N; i++)
{
if(A[i]!='z') flag=false;
}
if(flag && A[N]>C)
{
cout<<"NO\n";
continue;
}
flag=false;
for(int i=1; i<=N; i++) if(A[i]==C) flag=true;
if(!flag)
{
if(A[N]<=C)
{
A[N]=C;
}
else
{
int pos=-1;
for(int i=N-1; i>=1; i--)
{
if(A[i]!='z') { pos=i; break; }
}
A[pos]++;
for(int i=pos+1; i<=N; i++) A[i]='a';
A[N]=C;
}
}
if(A<B) cout<<string(A.begin()+1, A.end())<<"\n";
else cout<<"NO\n";
}
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3384kb
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: 1ms
memory: 3476kb
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: 3400kb
input:
308 16 r pppppppppppppppp pppppppppppppppq 183 h yadswtbucvyybqqbzelblcqjxodpsicgtjzagazrnqxycqhadpljbzlneduawfsfxxvoipdafjdpamgeydrjercplbvdbhieiofdgegkgxezghtwwhqzigfjgouvputfkmawngwgvgsknfkgupbwujaielpryeifgfukygdjxmvlkziruxbuxqz yadswtbucvyybqqbzelblcqjxodpsicgtjzagazrnqxycqhadpljbzlneduawfsfxxv...
output:
NO yadswtbucvyybqqbzelblcqjxodpsicgtjzagazrnqxycqhadpljbzlneduawfsfxxvoipdafjdpamgeydrjercplbvdbhieiofdgegkgxezghtwwhqzigfjgouvputfkmawngwgvgsknfkgupbwujaielpryeifgfukygdjxmvlkziruxbuxra rumfusabgtvavyqvmw lxnfntyxjpmtqnqubthagytoddtpqcxlexdtflwzyokizyrcqkpctbjewodyusiiepdvkmjouoajxwvapvtmatbnwbpsqq...
result:
ok OK!
Test #4:
score: 0
Accepted
time: 2ms
memory: 3412kb
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: 2ms
memory: 3504kb
input:
4 25000 h ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff...
output:
NO zxyyadswtbucvyybqqbzelblcqjxodpsicgtjzagazrnqxycqhadpljbzlneduawfsfxxvoipdafjdpamgeydrjercplbvdbhieiofdgegkgxezghtwwhqzigfjgouvputfkmawngwgvgsknfkgupbwujaielpryeiffukygdjxmvlkziruxbuxqzguhcevzputscajbughtgvtaevoywqbvkmgvtmitzclxnfntyxjpmtqnqubthagyoldfdqtcpsqwchxvlmenxfdstdfvlkwqzsygokkgimzsyprkc...
result:
ok OK!