답안 #497514

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
497514 2021-12-23T08:05:46 Z thekcc XOR (IZhO12_xor) C++14
0 / 100
1 ms 336 KB
#include <bits/stdc++.h>
using namespace std;

const int N = 500001;

int pre[N],a[N];
int bi,bk,n,x;

int main(){
	cin.tie(0)->sync_with_stdio(0);
	cin >> n;
	cin >> x;
	pre[0]=0;
	for(int i=1; i<=n; i++){
        cin >> a[i];
        pre[i]=pre[i-1]^a[i];
	}
	bi=-1;
	bk=-1;
	int k;
	for(int i=0; i<n; i++){
        for(int j=i+1; j<=n; j++){
            if(x==pre[j]^pre[i]){
                if(j-i>bk){
                   bi=i; bk=j-i;
                }
            }

        }
	}
	cout << bi+1 << " " << bk;
}

Compilation message

xor.cpp: In function 'int main()':
xor.cpp:23:17: warning: suggest parentheses around comparison in operand of '^' [-Wparentheses]
   23 |             if(x==pre[j]^pre[i]){
      |                ~^~~~~~~~
xor.cpp:20:6: warning: unused variable 'k' [-Wunused-variable]
   20 |  int k;
      |      ^
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 336 KB Output isn't correct
2 Halted 0 ms 0 KB -