QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#54208 | #855. A Very Different Word | ckiseki# | AC ✓ | 3ms | 3716kb | C++20 | 1.2kb | 2022-10-07 15:54:36 | 2022-10-07 15:54:37 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
int main() {
cin.tie(nullptr)->sync_with_stdio(false);
int t;
cin >> t;
while (t--) {
int n;
string x;
cin >> n >> x;
string a, b;
cin >> a >> b;
string ans = a;
ans.back() = x[0];
if (a < ans and ans < b) {
cout << ans << '\n';
continue;
}
if (ans.size() > 1) {
ans[ans.size() - 2]++;
for (size_t i = 2; i < ans.size(); ++i) {
int c = ans[ans.size() - i] - 'a';
if (0 <= c and c < 26)
break;
c %= 26;
ans[ans.size() - i] = 'a' + c;
ans[ans.size() - i - 1]++;
}
if (isalpha(ans[0]) and a < ans and ans < b) {
cout << ans << '\n';
continue;
}
}
ans = a;
ans.back()++;
for (size_t i = 1; i < ans.size(); ++i) {
int c = ans[ans.size() - i] - 'a';
if (0 <= c and c < 26)
break;
c %= 26;
ans[ans.size() - i] = 'a' + c;
ans[ans.size() - i - 1]++;
}
if (isalpha(ans[0]) and ans.find(x[0]) != string::npos and a < ans and ans < b) {
cout << ans << '\n';
continue;
}
cout << "NO\n";
}
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 2ms
memory: 3648kb
input:
4 10 m christmasa christmasx 6 m spring winter 21 a ithinkthereforeisleep ithinkthereforeithink 3 z tcs tcz
output:
christmasm sprinm ithinkthereforeislefa NO
result:
ok OK!
Test #2:
score: 0
Accepted
time: 2ms
memory: 3556kb
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:
christmasm ithinkthereforeislefa NO sprinm aaaaaaab aaabbbccl abcayaaaaaaaac christmasb abcabcxyyyyzlmnx 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: 3ms
memory: 3568kb
input:
308 16 r pppppppppppppppp pppppppppppppppq 183 h yadswtbucvyybqqbzelblcqjxodpsicgtjzagazrnqxycqhadpljbzlneduawfsfxxvoipdafjdpamgeydrjercplbvdbhieiofdgegkgxezghtwwhqzigfjgouvputfkmawngwgvgsknfkgupbwujaielpryeifgfukygdjxmvlkziruxbuxqz yadswtbucvyybqqbzelblcqjxodpsicgtjzagazrnqxycqhadpljbzlneduawfsfxxv...
output:
NO yadswtbucvyybqqbzelblcqjxodpsicgtjzagazrnqxycqhadpljbzlneduawfsfxxvoipdafjdpamgeydrjercplbvdbhieiofdgegkgxezghtwwhqzigfjgouvputfkmawngwgvgsknfkgupbwujaielpryeifgfukygdjxmvlkziruxbuxrh rumfusabgtvavyqvnr lxnfntyxjpmtqnqubthagytoddtpqcxlexdtflwzyokizyrcqkpctbjewodyusiiepdvkmjouoajxwvapvtmatbnwbpsqq...
result:
ok OK!
Test #4:
score: 0
Accepted
time: 3ms
memory: 3716kb
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: 3672kb
input:
4 25000 h ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff...
output:
NO zxyyadswtbucvyybqqbzelblcqjxodpsicgtjzagazrnqxycqhadpljbzlneduawfsfxxvoipdafjdpamgeydrjercplbvdbhieiofdgegkgxezghtwwhqzigfjgouvputfkmawngwgvgsknfkgupbwujaielpryeiffukygdjxmvlkziruxbuxqzguhcevzputscajbughtgvtaevoywqbvkmgvtmitzclxnfntyxjpmtqnqubthagyoldfdqtcpsqwchxvlmenxfdstdfvlkwqzsygokkgimzsyprkc...
result:
ok OK!