求助Atcoder
  • 板块学术版
  • 楼主yushanshui
  • 当前回复4
  • 已保存回复4
  • 发布时间2023/6/25 20:03
  • 上次更新2023/11/3 12:25:55
查看原帖
求助Atcoder
575532
yushanshui楼主2023/6/25 20:03

题目传送门, 程序WA了三个,在线求改正:

#include<bits/stdc++.h>
using namespace std;
bool is_palindrome(string s){
    string s2=s;
    reverse(s.begin(),s.end());
    return s==s2;
}
int n;
string s[110];
int main(){
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>s[i];
    }
    for(int i=1;i<n;i++){
        for(int j=i+1;j<=n;j++){
            if(is_palindrome(s[i]+s[j])){
                cout<<"Yes\n";
                return 0;
            }
        }
    }
    cout<<"No";
    return 0;
}
2023/6/25 20:03
加载中...