# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
503121 | LucaIlie | XOR (IZhO12_xor) | C++17 | 2044 ms | 916 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <iostream>
#include <set>
using namespace std;
#define MAX_N 100000
#define MAX_LOG_A 30
int v[MAX_N + 1];
int main() {
int n, a, x, y, temp, maxLen, poz, p, i, j;
maxLen = 0;
poz = -1;
cin >> n >> x;
for ( i = 1; i <= n; i++ ) {
cin >> a;
v[i] = v[i - 1] ^ a;
//printf( "%d ", v[i] );
y = 0;
for ( p = MAX_LOG_A; p >= 0; p-- ) {
if ( x & (1 << p) ) {
if ( (v[i] & (1 << p)) == 0 )
y += (1 << p);
} else {
temp = y;
if ( v[i] & (1 << p) )
y += (1 << p);
else
temp += (1 << p);
for ( j = 0; j < i; j++ ) {
if ( temp <= v[j] && v[j] <= temp + (1 << p) - 1 ) {
if ( i - j > maxLen ) {
maxLen = i - j;
poz = j + 1;
} else if ( i - j == maxLen ) {
if ( j + 1 < poz )
poz = j + 1;
}
}
}
}
}
for ( j = 0; j < i; j++ ) {
if ( (v[j] ^ v[i]) == x ) {
if ( i - j > maxLen ) {
maxLen = i - j;
poz = j + 1;
} else if ( i - j == maxLen ) {
if ( j + 1 < poz )
poz = j + 1;
}
}
}
}
cout << poz << " " << maxLen;
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |