求助,只能过hack 和点1

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

jiunichenyin @ 2024-03-20 11:18:27

#include<iostream>
#include<iomanip>
#include<math.h>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<string>
#include<queue>
#define maxn 100000000
using namespace std; 
struct bao {
    int x, y,zhi;
}b[maxn];
int point = 0;
int main() {
    int n, m;
    cin >> n >> m;
    for (int i = 0; i < m; ++i) {
        int pan;
        cin >> pan;
        if (pan == 1) {
            int x, y, zhi;
            cin >> x >> y >> zhi;
            b[point].x = x, b[point].y = y, b[point].zhi = zhi;
            point++;
        }
        else if (pan == 2) {
            int x, y;
            cin >> x >> y;
            for (int j = 0; j < point; ++j) {
                if (b[j].x == x && b[j].y == y) {
                    cout << b[j].zhi << endl;
                    break;
                }
            }
        }
    }
}

by tt2013331 @ 2024-07-18 20:48:51

@jiunichenyin

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

|