-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathninja3.cpp
More file actions
47 lines (44 loc) · 925 Bytes
/
Copy pathninja3.cpp
File metadata and controls
47 lines (44 loc) · 925 Bytes
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
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main()
{
int samples;
cin >> samples;
while (samples--)
{
ll n, m,count=0;
cin >> n >> m;
string a, b;
cin >> a >> b;
bool flag = true;
reverse(b.begin(), b.end());
a += b;
// cout<<a<<endl;
for (ll i = 0; i < a.length() - 2; i++)
{
if (a[i] == a[i + 1] && a[i] == a[i + 2])
{
//cout << "NO" << endl;
flag = false;
break;
}
}
for (ll i = 0; i < a.length()-1; i++)
{
if(a[i]==a[i+1]){
count++;
}
}
if(count>1){
flag=false;
}
if (flag)
{
cout << "YES" << endl;
}
else{
cout<<"NO"<<endl;
}
}
}