1 条题解

  • 0
    @ 2025-7-27 19:25:14
    #include<bits/stdc++.h>
    
    using namespace std;
    typedef long long LL;
    typedef pair<int, int> PII;
    
    #define x first
    #define y second
    
    const int N = 1e5 + 10, mod = 998244353;
    
    unordered_map<int, vector<int>> m;
    int a[N], x, n, q;
    
    bool check(int l, int r)
    {
        for(int i = l; i <= r; i ++)
        {
            int t = x ^ a[i];
            if(m.count(t))
            {
                auto j = lower_bound(m[t].begin(), m[t].end(), l);
                // auto k = lower_bound(m[t].begin(), m[t].end(), *j + 1);
                // if(j != m[t].end() && *j <= r && *j != i || k != m[t].end() && *k <= r && *k != i)
                //     return true;
                if(j != m[t].end() && *j <= r && *j != i)
                    return true;
            }
        }
        return false;
    }
    
    void solve()
    {
        cin >> n >> q >> x;
        for(int i = 1; i <= n; i ++)
        {
            cin >> a[i];
            m[a[i]].push_back(i);
        }
        
        for(auto i : m)
            sort(i.y.begin(), i.y.end());
            
        while(q --)
        {
            int l, r;
            cin >> l >> r;
            if(check(l, r)) cout << "Yes\n";
            else cout << "No\n";
        }
    }
    
    int main(){
        int t = 1;
        // cin >> t;
        while(t --)
            solve();
    }
    
    • 1

    信息

    ID
    432
    时间
    1000ms
    内存
    256MiB
    难度
    8
    标签
    递交数
    21
    已通过
    4
    上传者