-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathAMR12D.cpp
More file actions
64 lines (60 loc) · 1.16 KB
/
AMR12D.cpp
File metadata and controls
64 lines (60 loc) · 1.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<vector>
#include<queue>
#include<algorithm>
#include<set>
using namespace std;
#define mp make_pair
#define pb push_back
int t,n;
string s,temp;
bool calc(int x)
{
int i;
if(x<temp.size()-1)
return false;
for(i=x;x-i+1<=temp.size();i--)
{
if(temp[x-i]!=s[i])
return false;
}
return true;
}
int main()
{
bool flag=true,tf;
cin>>t;
while(t--)
{
flag=true;
cin>>s;
n=s.size();
for(int i=1;i<=n;i++)
{
for(int j=0;j<n-i+1;j++)
{
tf=false;
temp=s.substr(j,i);
//cout<<temp<<"\n";
for(int k=n-1;k>=0;k--)
{
if(s[k]==temp[0])
tf=calc(k);
if(tf)
break;
}
if(!tf)
{
//cout<<i<<" "<<j<<"\n";
flag=false;
}
}
}
if(flag)
cout<<"YES\n";
else
cout<<"NO\n";
}
}