全MLE???

P3613 【深基15.例2】寄包柜

a15801016376 @ 2024-01-19 10:05:31

本地测试结果都是正确的,为什么都超过限制了

#include<stdio.h>
#include<malloc.h>
#include<string.h>
#define len sizeof(struct node)
static int n,m;
int i,j,k,auto_data;
struct node{
    int id,a[10000];
    struct node *next;
};
struct node *creat(void){
    struct node *head,*p,*q;
    head=(struct node*)malloc(len);
    head->next=NULL;
    p=head;
    scanf("%d%d",&n,&m);
    for(int sum=1;sum<=n;sum++){
        q=(struct node*)malloc(len);
        q->id=sum;
        memset(p->a,0,sizeof(p->a));
        q->next=p->next;
        p->next=q;
        p=q;
    }
    p->next=NULL;
    return head;
}
void execute(struct node *head){
    struct node *pt;
    head=creat();
    pt=head;
    for(int sum=0;sum<m;sum++){
        scanf("%d",&auto_data);
        if(auto_data==1){
            scanf("%d%d%d",&i,&j,&k);
            while(i>=1){
                pt=pt->next;
                i--;
            }
            if(!k){pt->a[j]=0;}
            else pt->a[j]+=k;
        }
        else if(auto_data==2){
            scanf("%d%d",&i,&j);
            while(i>=1){
                pt=pt->next;
                i--;
            }
            printf("%d\n",pt->a[j]);
        }
        pt=head;
    }
}
int main(){
    struct node *head;
    execute(head);
    return 0;
}

by sss12 @ 2024-01-19 10:34:02

@a15801016376 内存超了,本地能运行是因为,题目只给了128MB,本地给的更多


|