제출 #418434

#제출 시각아이디문제언어결과실행 시간메모리
418434Runtime_error_XOR (IZhO12_xor)C++14
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> #define mp make_pair using namespace std; const int inf = 25e4+9,lg = 32; ll n,k,a[inf],pre[inf]; pair<ll,ll> ans; struct Trie{ ll cnt = 0,MinIdx = inf; Trie *a[2] = {0}; Trie(){ cnt = 0,MinIdx = inf; a[0] = a[1] = NULL; } void insert(ll bit,ll num,ll idx){ cnt++; MinIdx = min(MinIdx,idx); if(bit == -1) return ; bool CurBit = num & (1ll<<bit); if(a[CurBit] == NULL) a[CurBit] = new Trie(); a[CurBit]->insert(bit-1,num,idx); } ll query(ll bit,ll PreXor){ if(cnt == 0 || bit == -1) return MinIdx; bool PreBit = PreXor & (1ll<<bit); bool KBit = k & (1ll<<bit); if(a[0] == NULL) a[0] = new Trie(); if(a[1] == NULL) a[1] = new Trie(); if(KBit == 0){ if(PreBit) return min(a[1]->query(bit-1,PreXor),a[0]->MinIdx); else return min(a[0]->query(bit-1,PreXor),a[1]->MinIdx); } else { if(PreBit) return a[0]->query(bit-1,PreXor); else return a[1]->query(bit-1,PreXor); } } }; Trie *root = new Trie(); signed main(){ scanf("%lld%lld",&n,&k); for(ll i=1;i<=n;i++){ scanf("%lld",a+i); pre[i] = pre[i-1]^a[i]; root->insert(lg,pre[i-1],i-1); ans = max(ans,mp(i - root->query(lg,pre[i]),i)); } printf("%lld %lld\n",ans.second-ans.first+1,ans.first); }

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

xor.cpp:6:1: error: 'll' does not name a type; did you mean 'lg'?
    6 | ll n,k,a[inf],pre[inf];
      | ^~
      | lg
xor.cpp:7:6: error: 'll' was not declared in this scope; did you mean 'lg'?
    7 | pair<ll,ll> ans;
      |      ^~
      |      lg
xor.cpp:7:9: error: 'll' was not declared in this scope; did you mean 'lg'?
    7 | pair<ll,ll> ans;
      |         ^~
      |         lg
xor.cpp:7:11: error: template argument 1 is invalid
    7 | pair<ll,ll> ans;
      |           ^
xor.cpp:7:11: error: template argument 2 is invalid
xor.cpp:10:5: error: 'll' does not name a type; did you mean 'lg'?
   10 |     ll cnt = 0,MinIdx = inf;
      |     ^~
      |     lg
xor.cpp:16:17: error: 'll' has not been declared
   16 |     void insert(ll bit,ll num,ll idx){
      |                 ^~
xor.cpp:16:24: error: 'll' has not been declared
   16 |     void insert(ll bit,ll num,ll idx){
      |                        ^~
xor.cpp:16:31: error: 'll' has not been declared
   16 |     void insert(ll bit,ll num,ll idx){
      |                               ^~
xor.cpp:27:5: error: 'll' does not name a type; did you mean 'lg'?
   27 |     ll query(ll bit,ll PreXor){
      |     ^~
      |     lg
xor.cpp: In constructor 'Trie::Trie()':
xor.cpp:13:9: error: 'cnt' was not declared in this scope; did you mean 'int'?
   13 |         cnt = 0,MinIdx = inf;
      |         ^~~
      |         int
xor.cpp:13:17: error: 'MinIdx' was not declared in this scope
   13 |         cnt = 0,MinIdx = inf;
      |                 ^~~~~~
xor.cpp: In member function 'void Trie::insert(int, int, int)':
xor.cpp:17:9: error: 'cnt' was not declared in this scope; did you mean 'int'?
   17 |         cnt++;
      |         ^~~
      |         int
xor.cpp:18:9: error: 'MinIdx' was not declared in this scope
   18 |         MinIdx = min(MinIdx,idx);
      |         ^~~~~~
xor.cpp: In function 'int main()':
xor.cpp:54:23: error: 'n' was not declared in this scope; did you mean 'yn'?
   54 |     scanf("%lld%lld",&n,&k);
      |                       ^
      |                       yn
xor.cpp:54:26: error: 'k' was not declared in this scope
   54 |     scanf("%lld%lld",&n,&k);
      |                          ^
xor.cpp:55:9: error: 'll' was not declared in this scope; did you mean 'lg'?
   55 |     for(ll i=1;i<=n;i++){
      |         ^~
      |         lg
xor.cpp:55:16: error: 'i' was not declared in this scope
   55 |     for(ll i=1;i<=n;i++){
      |                ^
xor.cpp:56:22: error: 'a' was not declared in this scope
   56 |         scanf("%lld",a+i);
      |                      ^
xor.cpp:57:9: error: 'pre' was not declared in this scope
   57 |         pre[i] = pre[i-1]^a[i];
      |         ^~~
xor.cpp:59:36: error: 'struct Trie' has no member named 'query'
   59 |         ans = max(ans,mp(i - root->query(lg,pre[i]),i));
      |                                    ^~~~~
xor.cpp:61:30: error: request for member 'second' in 'ans', which is of non-class type 'int'
   61 |     printf("%lld %lld\n",ans.second-ans.first+1,ans.first);
      |                              ^~~~~~
xor.cpp:61:41: error: request for member 'first' in 'ans', which is of non-class type 'int'
   61 |     printf("%lld %lld\n",ans.second-ans.first+1,ans.first);
      |                                         ^~~~~
xor.cpp:61:53: error: request for member 'first' in 'ans', which is of non-class type 'int'
   61 |     printf("%lld %lld\n",ans.second-ans.first+1,ans.first);
      |                                                     ^~~~~