- problem link:http://codeforces.com/contest/1027/problem/A
- 第一次写用了48行,第二次写用了12行。还是做题太少。心塞塞。
小闵呀,加油!!!
#include<bits/stdc++.h>
using namespace std;
int main(){
int T;cin>>T;
while(T--){
int i,j,n,flag=1;string s;cin>>n>>s;
for(i=0,j=n-1;i<j;i++,j--){
if(s[i]==s[j])continue;
if(!(abs(s[i]-s[j])==2))flag=0;
}
if(flag)puts("YES");else puts("NO");
}
}

本文分享了在CodeForces平台上的A级题目从48行代码精简到12行的过程及心得。通过对字符串的巧妙处理,实现了更简洁高效的解决方案。

被折叠的 条评论
为什么被折叠?



