如果你是好心人 就点进来 ——为什么T??
查看原帖
如果你是好心人 就点进来 ——为什么T??
819273
LIUYC_C楼主2023/3/31 22:43
#include <bits/stdc++.h>
using namespace std;
const int mod=20123;
int a[10006][104];
int n,m;
queue<int> q; 
int find(int start,int n){
    for(int i=start;i<=n;i++){
        if(a[i][1]==1) return i;
    }
    for(int i=i-m+1;i<=start;i++){
        if(a[i][1]==1) return i;
    }
}

void cz(){
	int t=q.front();
	q.pop();
	q.push(t);
}
void csh(int start){
	while(q.front()!=start){
		int t=q.front();
		q.pop();
		q.push(t);
	}
}
int main(){
	cin>>n>>m;
	
	for(int i=1;i<=n*m;i++){
		for(int j=1;j<=2;j++){
			scanf("%d",&a[i][j]);
		}
	}
	int start;
	cin>>start;
	start+=1;
	int ans=0;
	int flag;
	for(int i=1;i<=m*n;i++){
		
		if(a[i][1]==1){ //楼梯 
			q.push(i);
		}
		if(i%m==0){
		    
			ans=(ans+a[start][2])%mod;	
			int ss;
			if(a[start][1]==0){
				int res=start;
				ss=find(start,i);
				
				csh(ss); 
			}
			else{
				ss=a[start][2];
				csh(ss);
			}
			//cout<<q.front()<<endl;
			int h=a[start][2]-1;//这里改成不减//一就不T了md为什么???
			while(h--){
			    int t=q.front();
	            q.pop();
	            q.push(t);
			}
		
			start=q.front()+m;
			while(q.size()) q.pop();	
		}
	}
	cout<<ans;
} 
2023/3/31 22:43
加载中...