下面是90分代码:
#include <bits/stdc++.h>
using namespace std;
const int mod=20123;
struct node{
int s,x;
};
int main(){
int n,m,op,count=1,k=0,sum=0;
scanf("%d%d",&n,&m);
node f[10005][105];
for(int i=1;i<=n;i++){
for(int j=0;j<m;j++){
scanf("%d%d",&f[i][j].s,&f[i][j].x);
if(f[i][j].s==1)f[i][m].s++;
}
}
scanf("%d",&op);
while(count<=n){
k=0;
sum+=f[count][op].x;
sum%=mod;
for(int i=op;;i++){
if(i==m)i=0;
if(f[count][i].s==1)k++;
if(k==(f[count][op].x-1)%f[count][m].s+1){
op=i;
break;
}
}
count++;
}
cout<<sum;
return 0;
}
题目数据说好的n<=10000,m<=100呢?
(后来发现WA的点的数据确实m确实是100没超,但是为什么会WA?????)
求大佬指点迷津,万分感谢!!!