QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#114545 | #855. A Very Different Word | EastKing# | AC ✓ | 2ms | 3608kb | C++14 | 957b | 2023-06-22 15:25:51 | 2023-06-22 15:25:52 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
const int M=1e5+5,P=26;
char op[5],A[M],B[M];
int sum[M],n;
void solve(){
for(int i=0;i<n;i++){
sum[i]=A[i]-'a';
}
sum[n]=0;
reverse(sum,sum+n);
for(int i=1;i<=26;i++){
sum[0]++;
bool f=0;
for(int i=0;i<n;i++){
sum[i+1]+=sum[i]/P;
sum[i]%=P;
if(sum[i]==op[0]-'a')f=1;
}
if(sum[n]>0){
cout<<"NO\n";
return;
}
if(f){
reverse(sum,sum+n);
for(int i=0;i<n;i++){
A[i]=sum[i]+'a';
}
A[n]=0;
//cerr<<"check:"<<A<<'\n';
bool flag=0;
for(int i=0;i<n;i++){
if(A[i]==B[i])continue;
if(A[i]<B[i]){
flag=1;
break;
}
}
//cout<<"ans:";
if(!flag)cout<<"NO\n";
else {
A[n]=0;
cout<<A<<'\n';
}
return;
}
}
cout<<"NO\n";
}
int main(){
ios::sync_with_stdio(false);
cin.tie(0);
int cas;
cin>>cas;
while(cas--){
cin>>n>>op>>A>>B;
solve();
}
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3448kb
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: 3488kb
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: 3444kb
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: 3452kb
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: 3608kb
input:
4 25000 h ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff...
output:
NO zxyyadswtbucvyybqqbzelblcqjxodpsicgtjzagazrnqxycqhadpljbzlneduawfsfxxvoipdafjdpamgeydrjercplbvdbhieiofdgegkgxezghtwwhqzigfjgouvputfkmawngwgvgsknfkgupbwujaielpryeiffukygdjxmvlkziruxbuxqzguhcevzputscajbughtgvtaevoywqbvkmgvtmitzclxnfntyxjpmtqnqubthagyoldfdqtcpsqwchxvlmenxfdstdfvlkwqzsygokkgimzsyprkc...
result:
ok OK!