-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path1553B Reverse String.cpp
42 lines (41 loc) · 964 Bytes
/
1553B Reverse String.cpp
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
/*
author : MishkatIT
created : Monday 2023-01-30-20.19.58
*/
#include<bits/stdc++.h>
#define fio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;
int main()
{
fio;
int t;
cin >> t;
while(t--)
{
string str, target;
cin >> str >> target;
int n = (int)str.length();
int x = 0;
bool ok = false;
for (int i = 0; i < n; i++)
{
string temp;
for (int j = 0; j <= i; j++)
temp += str[j];
for (int j = i - 1; j >= 0; j--)
temp += str[j];
// static int tt = 0;
// cout << ++tt << ' ' << temp << '\n';
if(temp.find(target) != string::npos)
{
cout << "YES" << '\n';
ok = true;
}
if(ok)
break;
}
if(!ok)
cout << "NO" << '\n';
}
return 0;
}