Problem - A - Codeforces
给定一些字符子串的前缀或后缀,判断这个串是不是回文串
#include <iostream>
#include <bits/stdc++.h>
#include <cstring>
#include <vector>
#include <algorithm>
#define x first
#define y second
#define fu(i,a,b) for(int i=a;i<=b;i ++ )
#define fd(i,a,b) for(int i=a;i>=b;i -- )
#define endl '\n'
#define ms(x,y) memset(x,y,sizeof x)
#define ios ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
using namespace std;
typedef long long LL;
typedef pair<int,int> PII;
typedef pair<double,double> PDD;
typedef pair<double,int> PDI;
typedef pair<char,int> PCI;
typedef pair<string,int> PSI;
typedef pair<int,string> PIS;
typedef pair<LL,LL> PLL;
//typedef __int128 i128;
typedef unsigned long long ULL;
const int N = 1e5+ 10,M = 1e5 + 10,INF = 0x3f3f3f3f ;
const int mod = 1e9;
const double eps = 1e-8;
int n;
inline void solve()
{
cin >> n;
vector<string > a;
fu(i,0,2 * n -3)
{
string s;cin >>s;
if(s.size() == n -1 ) a.push_back(s);
// 找到长度刚好 == 总串长度-1的串,一个总串只会有两个这种串
}
if(a[0] == string(a[1].rbegin(),a[1].rend()))
// 看看两个串 一个是总串前面 一个是总串的 后面 ,如果这两个串相等的话原串就是回文串
cout <<"YES\n";
else cout << "NO\n";
}
signed main()
{
// freopen("1.txt","w",stdout);
ios
int t=1;
cin>>t;
int now = 1;
while(t -- )
{
// cout<<"Case ";
// cout<<"Case #";
// cout<< now ++ <<": ";
solve();
}
return 0;
}