rt,求调。
求调,求调,求调。qaq
#include<bits/stdc++.h>
using namespace std;
#define LL long long
#define ull unsigned long long
LL m,q;
string s;
LL i;
LL x;
LL len;
LL dfs(LL now){
if(s[now]!='x'){
// cout<<now<<" 111111111\n";
for(i=now;i<=len;i++){
if(s[i]==':'||s[i]=='?')break;
cout<<s[i];
}
cout<<"\n";return -1;
}
LL num=0;
LL j;
for(j=now+2;j<=len;j++){
if(s[j]==':'||s[j]=='?')break;
num=num*10+s[j]-'0';
}
if(s[now+1]=='>'){
if(x<=num){
LL tamp=0;
bool flag=0;
for(i=j;i<=len;i++){
if(s[i]=='?')tamp++;
else if(s[i]==':')tamp--;
if(!tamp){
return i+1;
}
}
}
else{
return (j+1);
}
}
if(s[now+1]=='<'){
if(x>=num){
LL tamp=0;
for(i=j;i<=len;i++){
if(s[i]=='?')tamp++;
else if(s[i]==':')tamp--;
if(!tamp){
return (i+1);
}
}
}
else{
return (j+1);
}
}
return 0;
}
int main(){
cin>>m>>q>>s;
len=s.size();
s=" "+s+" ";
LL cnt=0;
while(q--){
// if(cnt==0){
// cout<<s<<"\n";continue;
// }
cin>>x;
LL now=dfs(1);
while(now!=-1)now=dfs(now);
}
return 0;
}