-
Notifications
You must be signed in to change notification settings - Fork 0
/
CON7_10.cpp
49 lines (48 loc) · 1.24 KB
/
CON7_10.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
42
43
44
45
46
47
48
49
#include <bits/stdc++.h>
using namespace std;
string test(string s){
bool check = false;
string ans = "";
for (int i = 0; i < s.size(); i++){
if (s[i] == '('){
continue;
}else if (s[i] == ')'){
check = false;
}else if (s[i] == '+'){
if (check){
ans += '-';
}else{
ans += '+';
}
}else if (s[i] == '-'){
if (check && s[i+1] != '('){
ans += '+';
}else if (check && s[i + 1] == '('){
check = false;
ans += '+';
}else if (s[i + 1] == '('){
check = true;
ans += '-';
}else{
ans += '-';
}
}else {
ans += s[i];
}
if (check && s[i] == ')'){
check = false;
}
}
return ans;
}
int main(){
int t; cin >> t;
while(t--){
string s1, s2; cin >> s1 >> s2;
if (test(s1) == test(s2)){
cout<<"YES"<<endl;
}else{
cout<<"NO"<<endl;
}
}
}