제출 #79895

#제출 시각아이디문제언어결과실행 시간메모리
79895imeimi2000XOR (IZhO12_xor)C++17
100 / 100
1272 ms41896 KiB
#include <cstdio>
#include <unordered_map>

using namespace std;
typedef long long llong;
typedef pair<int, int> pii;

int n, k;
int ansi, ansk = 0;
int a[250001];
int main() {
    scanf("%d%d", &n, &k);
    for (int i = 1; i <= n; ++i) {
        scanf("%d", a + i);
        a[i] ^= a[i - 1];
    }
    if (k == 0) {
        printf("1 %d\n", n);
        return 0;
    }
    --k;
    for (int i = 0; i < 30; ++i) {
        if ((k >> i) & 1) continue;
        int x = (k >> i) ^ 1;
        unordered_map<int, int> mp;
        for (int j = 0; j <= n; ++j) mp[a[j] >> i] = j;
        for (int j = 0; j <= n; ++j) {
            int mx = mp[(a[j] >> i) ^ x];
            if (ansk < mx - j) ansk = mx - j, ansi = j + 1;
            else if (ansk == mx - j && j + 1 < ansi) ansi = j + 1;
        }
    }
    printf("%d %d\n", ansi, ansk);
    return 0;
}

컴파일 시 표준 에러 (stderr) 메시지

xor.cpp: In function 'int main()':
xor.cpp:12:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d%d", &n, &k);
     ~~~~~^~~~~~~~~~~~~~~~
xor.cpp:14:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d", a + i);
         ~~~~~^~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...