20分WA2,3,4,5,求助

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

pxlamda @ 2023-02-28 23:49:47

#include<iostream>
#include<unordered_map>
#include<string>

using namespace std;

int main() 
{
    int n, q,xingwei, k;
    cin >> n >> q;
    string hang, lie, str;
    unordered_map<string, int> hash;
    for (int i = 0; i < q; i++) 
    {
        cin >> xingwei;
        if (xingwei == 1) 
        {
            cin >> hang >> lie >> k;
            str = hang + ',' + lie;
            hash.emplace(str, k);
        }
        else
        {
            cin >> hang >> lie;
            str = hang + ',' + lie;
            int result = hash.at(str);
            cout << result << endl;
        }
    }

    return 0;
}

by pxlamda @ 2023-03-01 19:21:44

居然过了,原来是只要k=0的时候不输出就行了


|