1 条题解

  • 0
    @ 2024-7-25 13:33:03

    参考答案:

    #include<iostream>
    #include<cstring>
    
    using namespace std;
    
    const int N = 200003, null = 0x3f3f3f3f;
    int h[N];
    
    int find(int x)
    {
        int t = ((x % N) + N) % N;
    
        while (h[t] != null && h[t] != x)
        {
            ++t;
            if (t == N) t = 0;
        }
    
        return t;
    }
    int main()
    {
        memset(h, 0x3f, sizeof(h));
        int n;
    
        cin >> n;
        while (n--)
        {
            int x;
            char op[2];
            scanf("%s%d", op, &x);
            if (*op == 'I') h[find(x)] = x;
            else
            {
                if (h[find(x)] == x) cout << "Yes" << endl;
                else cout << "No" << endl;
            }
        }
    
        return 0;
    }
    
    • 1

    信息

    ID
    86
    时间
    1000ms
    内存
    256MiB
    难度
    10
    标签
    递交数
    1
    已通过
    1
    上传者