RE求调
  • 板块灌水区
  • 楼主WoodReal12
  • 当前回复1
  • 已保存回复2
  • 发布时间2024/7/16 19:16
  • 上次更新2024/7/16 20:18:30
查看原帖
RE求调
676569
WoodReal12楼主2024/7/16 19:16

站外题,不用调我的其他问题,把re调好就行(数据范围和一组数据放代码后面)

code:

#include <bits/stdc++.h>
using namespace std;
const int N=500010;
string s;
int n,m,to[N];
bool a[N];
signed main(){
	// freopen("ball.in","r",stdin);
	// freopen("ball.out","w",stdout);
	ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
	cin>>n>>m;
	for(int i=1;i<=n;i++){
		cin>>s[i];
		if(s[i]=='/')
			a[i]=1;
	}
	for(int i=1;i<=n;i++){
		int tmp=i;
		while(1){
			if(a[tmp]==0){
				if(tmp<=n-1&&a[tmp+1]==0)
					tmp++;
				else{
					to[i]=tmp;
					break;
				}						
			}
			else{
				if(tmp>=2&&a[tmp-1])
					tmp--;
				else{
					to[i]=tmp-1;
					break;
				}
			}
		}
	} 
	while(m--){
		int l,r;
		cin>>l>>r;
		for(int i=l;i<=r;i++)
			a[i]=!a[i];
		for(int i=l;i<=r;i++){
			int tmp=i;
			while(1){//man what can i say
				if(a[tmp]==0){
					if(tmp<=n-1&&a[tmp+1]==0)
						tmp++;
					else{
						to[i]=tmp;
						break;
					}						
				}
				else{
					if(tmp>=2&&a[tmp-1]==1)
						tmp--;
					else{
						to[i]=tmp-1;
						break;
					}
				}
			}
		} 
		vector<int> tong(n+1);
		for(int i=l;i<=r;i++)
			tong[to[i]]++;
		int ans=-1;
		for(int i=0;i<=n;i++)
			ans=max(ans,tong[i]);
		cout<<ans<<endl;
	}
	return 0;
}

数据范围

n,m≤5000n,m\le5000

RE的输入:here

玄一关

2024/7/16 19:16
加载中...