测试点就第2个 RE,求助!!
查看原帖
测试点就第2个 RE,求助!!
538085
liysjianttso楼主2023/4/5 19:35

哪位大佬帮忙看看有什么问题,谢谢了 如下:

#include<stdio.h>
struct room{
	int is,abs;
};
int n,m,now,ans;
room f[10000][110];//房间数据
int l[10000];//每层楼有楼梯的房间的个数
int round(int n,int now,int abs){//用来逆时针寻找
	int count = 1;
	while(count<=abs){
		now = now%m+1;
		if(f[n][now].is==1)count++;
	}
	return now;
}
void act(int n){//更改now的值
	if(f[n][now].is==1){
		int exact = f[n][now].abs;
		int ext = (exact-1)%l[n]+1;
		now = round(n,now,ext-1);
		
	}
	else{
		int exact = f[n][now].abs;
		int ext = (exact-1)%l[n]+1;
		now = round(n,now,ext);
		
	}
}
int main(){
	scanf("%d%d",&n,&m);
	
	for(int i = 1;i<=n;i++){
		for(int j = 1;j<=m;j++){
			scanf("%d%d",&f[i][j].is,&f[i][j].abs);
			l[i]+=f[i][j].is;//带楼梯的房间数
		}
	}
	scanf("%d",&now);
	now++;//序号从零开始
	
	for(int i = 1;i<=n;i++){
		ans+=f[i][now].abs;
		ans%=20123;
		act(i);
	}
	
	printf("%d",ans);
	return 0;
}
2023/4/5 19:35
加载中...