-
Notifications
You must be signed in to change notification settings - Fork 0
/
22343.cpp
44 lines (44 loc) · 861 Bytes
/
22343.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
#include <iostream>
#include <string>
#include <vector>
#include <cstring>
#include <algorithm>
using namespace std;
int T,m;
string a,b;
vector<int> sol2(string s){
vector<int> ret(m+1);
int cur=0;
for(int i=0;i<s.size();i++){
if(s[i]=='(') cur++;
else {
cur--;
if(s[i-1]=='('){
ret[cur]++;
}
}
}
for(int i=0;i<ret.size()-1;i++){
ret[i+1]+=ret[i]/2;
ret[i]%=2;
}
return ret;
}
string sol(){
vector<int> pa = sol2(a);
vector<int> pb = sol2(b);
for(int i=pa.size()-1;i>=0;i--){
if(pa[i] < pb[i]) return "<";
if(pa[i] > pb[i]) return ">";
}
return "=";
}
int main(){
cin >> T;
while(T--){
cin >> a >> b;
m=max(a.size(),b.size());
m/=2;
cout << sol() << '\n';
}
}