| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 | 
|---|---|---|---|---|---|---|---|
| 1049319 | sofija6 | XOR (IZhO12_xor) | C++14 | 1 ms | 2396 KiB | 
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define ll long long
#define MAXN 250010
using namespace std;
ll a[MAXN],pref[MAXN];
map<ll,ll> pos;
int main()
{
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    ll n,x,ansi=0,ansk=0;
    cin >> n >> x;
    for (ll i=1;i<=n;i++)
    {
        cin >> a[i];
        pref[i]=pref[i-1]^a[i];
    }
    for (ll i=n;i>=0;i--)
    {
        ll val=0;
        for (ll j=30;j>=0;j--)
        {
            if ((1<<j)&x)
            {
                if (!((1<<j)&pref[i]))
                    val+=(1<<j);
                continue;
            }
            if (!((1<<j)&pref[i]))
                val+=(1<<j);
            if (pos[val]-i>ansk)
            {
                ansk=pos[val]-i;
                ansi=i+1;
            }
            else if (pos[val]-i==ansk)
                ansi=i+1;
            val^=(1<<j);
        }
        if (!pos[pref[i]])
            pos[pref[i]]=i;
        for (ll j=0;j<=30;j++)
        {
            if ((1<<j)&pref[i])
                pref[i]-=(1<<j);
            if (!pos[pref[i]])
                pos[pref[i]]=i;
        }
    }
    cout << ansi << " " << ansk;
    return 0;
}
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
