M L E!!!!!!!!!!!!!!!

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

vector_STL_ @ 2024-10-31 14:14:52

#include <iostream>
using namespace std;

/*#define int long long*/
int main() {
    int n, m;
    cin >> n >> m;
    short f[n][10000];
    for(int i=0;i<n;i++){
        for(int j=0;j<10000;j++){
            f[i][j]=0;
        }
    }
    for (int i = 0; i < m; i++) {
        int a, b, c;
        cin >> a >> b >> c;
        if (a == 1) {
            int d;
            cin >> d;
            f[b][c] = d;
        }
        if (a == 2) {
            cout << f[b][c] << "\n";
        }
    }
    return 0;
}

by charlieqi @ 2024-10-31 14:20:01

建议用MAP

#include<bits/stdc++.h>
using namespace std;
int n,q,x,i,j,k;
map<long long,long long>mp;
int main(){
    cin>>n>>q;
    while(q--){
        cin>>x;
        if(x==1){
            cin>>i>>j>>k;
            mp[i*100000000000+j]=k;
        }else{
            cin>>i>>j;
            cout<<mp[i*100000000000+j]<<"\n";
        }
    }
    return 0;
} 

by vector_STL_ @ 2024-10-31 14:22:51

@charlieqi

Unknow Error


|