测试点就第2个 RE,求助!!

P1076 [NOIP2012 普及组] 寻宝

数组定义小了
by Felix66 @ 2023-05-14 18:49:54


```cpp #include<stdio.h> struct room{ int is,abs; }; int n,m,now,ans; room f[100000][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; } ```
by JYW2011 @ 2023-06-06 20:12:07


abs是关键语句,要换一个
by chen_zhe_shishabi @ 2023-07-08 14:08:38


|