64pts TLE 求调
  • 板块P11186 三目运算
  • 楼主xyx404
  • 当前回复1
  • 已保存回复1
  • 发布时间2024/10/13 17:11
  • 上次更新2024/10/13 19:24:38
查看原帖
64pts TLE 求调
1123573
xyx404楼主2024/10/13 17:11

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;
}
2024/10/13 17:11
加载中...