Submission #13342

#TimeUsernameProblemLanguageResultExecution timeMemory
13342dohyun0324XOR (IZhO12_xor)C++98
Compilation error
0 ms0 KiB
#include<stdio.h> #include<unordered_map> #include<string.h> using namespace std; map<int,int>ch; int ans,p,len,n,x,a[250010],b[250010],sum[250010],dap[250010],t,r; int main() { int i,j; scanf("%d %d",&n,&x); for(i=1;i<=n;i++) scanf("%d",&a[i]); for(i=30;i>=0;i--){ r=1<<i; t+=r; if(x&r){ for(j=1;j<=n;j++){ if(r&a[j]) b[j]+=r; sum[j]=sum[j-1]^b[j]; } } else{ for(j=1;j<=n;j++){ if(r&a[j]) b[j]+=r; sum[j]=sum[j-1]^b[j]; ch[sum[j]]=j; } for(j=1;j<=n;j++) dap[j]=max(dap[j],ch[sum[j-1]^t]); for(j=1;j<=n;j++) ch[sum[j]]=0; t-=r; } } for(j=1;j<=n;j++) ch[sum[j]]=j; for(j=1;j<=n;j++) dap[j]=max(dap[j],ch[sum[j-1]^t]); for(i=1;i<=n;i++){ if(ans<dap[i]-i+1) ans=dap[i]-i+1, p=i; } printf("%d %d",p,ans); return 0; }

Compilation message (stderr)

In file included from /usr/include/c++/4.9/unordered_map:35:0,
                 from xor.cpp:2:
/usr/include/c++/4.9/bits/c++0x_warning.h:32:2: error: #error This file requires compiler and library support for the ISO C++ 2011 standard. This support is currently experimental, and must be enabled with the -std=c++11 or -std=gnu++11 compiler options.
 #error This file requires compiler and library support for the \
  ^
xor.cpp:5:1: error: ‘map’ does not name a type
 map<int,int>ch;
 ^
xor.cpp: In function ‘int main()’:
xor.cpp:24:17: error: ‘ch’ was not declared in this scope
                 ch[sum[j]]=j;
                 ^
xor.cpp:26:49: error: ‘ch’ was not declared in this scope
             for(j=1;j<=n;j++) dap[j]=max(dap[j],ch[sum[j-1]^t]);
                                                 ^
xor.cpp:26:63: error: ‘max’ was not declared in this scope
             for(j=1;j<=n;j++) dap[j]=max(dap[j],ch[sum[j-1]^t]);
                                                               ^
xor.cpp:27:31: error: ‘ch’ was not declared in this scope
             for(j=1;j<=n;j++) ch[sum[j]]=0;
                               ^
xor.cpp:31:23: error: ‘ch’ was not declared in this scope
     for(j=1;j<=n;j++) ch[sum[j]]=j;
                       ^
xor.cpp:32:41: error: ‘ch’ was not declared in this scope
     for(j=1;j<=n;j++) dap[j]=max(dap[j],ch[sum[j-1]^t]);
                                         ^
xor.cpp:32:55: error: ‘max’ was not declared in this scope
     for(j=1;j<=n;j++) dap[j]=max(dap[j],ch[sum[j-1]^t]);
                                                       ^
xor.cpp:10:25: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d %d",&n,&x);
                         ^
xor.cpp:11:40: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
     for(i=1;i<=n;i++) scanf("%d",&a[i]);
                                        ^