与排第一的题解方法一致但是全部RE

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

realec @ 2021-10-28 21:46:28

#include <iostream>
#include <vector>
using namespace std;
struct cabinet
{
    vector <int> id,item;
    int num = -1;
}cab [10005];
int main ()
{
    int n,q;
    cin >> n >> q;
    while (q--)
    {
        int t ;
        cin >> t;
        int i , j , k;
        if (t == 1)
        {
            cin >> i >> j >> k;
            cab[i].num ++;
            cab[i].id.push_back(j);
            cab[i].item.push_back(k);
        }
        else if (t == 2)
        {
            cin >> i >> j;
            for (int ii = cab[i].num ; ii >= 0  ;--ii )
            {
                if (cab[i].id[ii] == j )
                {
                    cout << cab[i].item[ii] << endl;
                    break;
                }
            }
        }
    }
}

by Echidna @ 2021-10-28 21:49:21

@realec 数组开小了

话说代码这么短,RE不就几个原因吗……


by realec @ 2021-11-16 17:25:25

@某学oi的蒟蒻 确实,不过我也忘了后面怎么改的,反正就过了


|