제출 #1085489

#제출 시각아이디문제언어결과실행 시간메모리
1085489SunbaeXOR (IZhO12_xor)C++17
0 / 100
0 ms600 KiB
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 5; int a[N], has[32][N], qs[N], f[32]; signed main(){ int n, x, t, mx; scanf("%d %d", &n, &x); //if(!x){ printf("1 %d", n); return 0;} t = mx = 31 - __builtin_clz(x); memset(f, -1, sizeof(f)); for(int i = 0; i<n; ++i){ scanf("%d", a+i); qs[i] = (i ? qs[i-1] : 0) ^ a[i]; int f_b = 31 - __builtin_clz(a[i]); mx = max(mx, f_b); for(int j = 0; j<=f_b; ++j){ if(a[i]>>j&1){ has[j][i] = 1; if(f[j] == -1) f[j] = i; } } } int mx_len = 0, min_st = n; for(int j = t+1; j<=mx; ++j){ int r_s = 0; for(int i = 0; i<n; ++i){ r_s += has[j][i]; if(r_s&1){ int len = i+1, st = 1; if(len > mx_len) mx_len = len, min_st = st; else if(len == mx_len && st < min_st) min_st = st; }else if(f[j] != -1 && f[j] < i){ int len = i - f[j], st = f[j]+2; if(len > mx_len) mx_len = len, min_st = st; else if(len == mx_len && st < min_st) min_st = st; } } } int r_s = 0; for(int i = 0, j = t; i<n; ++i){ r_s += has[j][i]; if((r_s&1) && qs[i] >= x){ int len = i+1, st = 1; if(len > mx_len) mx_len = len, min_st = st; else if(len == mx_len && st < min_st) min_st = st; }else if((f[j] != -1) && (f[j] < i) && ((qs[i] ^ qs[f[j]]) >= x)){ int len = i - f[j], st = f[j]+2; if(len > mx_len) mx_len = len, min_st = st; else if(len == mx_len && st < min_st) min_st = st; } } printf("%d %d", min_st, mx_len); }

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

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