水水水

#include "cstdio"
#include "algorithm"
#include "iostream"
using namespace std;
int a[50010][60];
int b[10001],c[101];
int main(){
    int n , m , t;
    int f,sum;
    scanf ("%d%d%d",&n,&m,&t);
           sum=0;
           for (int i = 1 ; i <= n; i++){
                  for (int j = 1; j <= m ; j++){
                         scanf ("%d",&a[i][j]);
                  }
           }
           for (int i = 1  ;i <= t; i++)scanf ("%d%d",&b[i],&c[i]);//b[i] 第几题  c[i]  题目的答案 
           
                  for (int j = 1 ; j <= n ; j++){
                                       f=0;
                           for (int i = 1 ; i <= t; i++){
                                  if (a[j][b[i]]==c[i]){      //如果对不上 
                                            f++; 
                                  }
                          }
                          if (f==t){
                                  sum=sum+1;
                          }
                  }    
            printf ("%d
",sum);
}

牛客上面的题目,我一共提交了9次,前面8次超内存,我就奇了怪了,之前做题的时候可没这种错误。毫无头绪!我想这题应该只是简单的模拟才对,后来突然发现,我貌似数组开大了,仔细一看,题意是开一个n*m数组,n<50000,m<50。我之前开的n*n 。= = ,还是太菜了。

原文地址:https://www.cnblogs.com/AChappy/p/11964494.html