-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path030-p-np.cpp
More file actions
46 lines (42 loc) · 905 Bytes
/
Copy path030-p-np.cpp
File metadata and controls
46 lines (42 loc) · 905 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
/*
* P=NP [106251B]
* Problem: Gym/ICPC contest 106251 - problem B
* Verdict: ACCEPTED Solved: 2026-06-20
* Language: C++20 (GCC 13-64)
* Runtime: 31 ms Memory: 100 KB
* Tags: n/a
* Author: team "balls" (HossamIsmail, BidoTeima, a1abay)
* Source: https://codeforces.com/gym/106251/submission/379571881
*/
#include <bits/stdc++.h>
using namespace std;
const int sz = 8e3 + 2;
void solve()
{
string a, b;
cin >> a >> b;
while(a.back() == b.back() && a.back() == 'N')
{
a.pop_back();
b.pop_back();
}
if(a.back() == b.back() && count(a.begin(), a.end(), 'P') == count(b.begin(), b.end(), 'P'))
{
cout << "YES" << '\n';
}
else
{
cout << "NO" << '\n';
}
}
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
int t = 1;
cin >> t;
while(t--)
{
solve();
}
}