제출 #1101688

#제출 시각아이디문제언어결과실행 시간메모리
1101688theflessXOR (IZhO12_xor)C++17
100 / 100
95 ms120768 KiB
#include<bits/stdc++.h> using namespace std; #define MASK(i) (1LL << (i)) #define BIT(x, i) (((x) >> (i)) & 1) #define Times (1.0 * clock() / CLOCKS_PER_SEC) #define fi first #define base 31 #define sz(x) (int)(x).size() #define se second #define ll long long #define mp make_pair #define pb push_back #define pii pair<int, int> #define all(x) (x).begin(), (x).end() #define file(name) if (fopen(name".inp", "r")) { freopen(name".inp", "r", stdin); freopen(name".out", "w", stdout); freopen(name".bug", "w", stderr); } #define task "name" #define tsk "" const int oo = 1e9 + 7; const ll loo = (ll)1e18 + 7; const int MOD = 1e9 + 7; const int MOD2 = 1e9 + 696969; const int N = 250000 + 3; const int BASE = 10; template <typename T1, typename T2> bool minimize(T1 &a, T2 b){if (a > b) {a = b; return true;} return false;} template <typename T1, typename T2> bool maximize(T1 &a, T2 b){if (a < b) {a = b; return true;} return false;} int n , x; int a[N]; struct TRIE{ struct NODE{ int cnt, idx; int child[2]; NODE(){cnt = child[0] = child[1] = 0;idx = oo;} }t[N * 30]; int cnt; void add(int s, int vt){ int root = 0; for(int i = 30 ; i >= 0 ; i--){ int id = BIT(s , i); if(!t[root].child[id]) t[root].child[id] = ++cnt; root = t[root].child[id]; t[root].cnt++; minimize(t[root].idx , vt); } } int dfs(int root , int s , int dept){ if(root == 0 && dept != 30) return oo; if(dept < 0) return t[root].idx; int l = t[root].child[0]; int r = t[root].child[1]; if(BIT(s , dept)) swap(l , r); if(BIT(x , dept)){ int res = dfs(r , s , dept - 1); return res; } int res = dfs(l , s , dept - 1); return min(t[r].idx , res); } }trie; void Solve(){ cin >> n >> x; for(int i = 1 ; i <= n ; i++) cin >> a[i]; trie.add(0 , 0); int pre = 0 , siz = 0 , st = 0; for(int i = 1 ; i <= n ; i++){ pre ^= a[i]; int w = trie.dfs(0 , pre , 30); if(w != oo){ if(maximize(siz , i - w)) st = w + 1; } trie.add(pre , i); } cout << st << ' ' << siz; } int main() { ios_base::sync_with_stdio(0); cin.tie(0); file(task); file(tsk); int T = 1; // cin >> T; while(T--) { Solve(); } cerr << "Time elapsed: " << Times << " s.\n"; return 0; } // author: thefless

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

xor.cpp: In function 'int main()':
xor.cpp:16:58: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   16 | #define file(name)  if (fopen(name".inp", "r")) { freopen(name".inp", "r", stdin); freopen(name".out", "w", stdout); freopen(name".bug", "w", stderr); }
      |                                                   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
xor.cpp:82:5: note: in expansion of macro 'file'
   82 |     file(task);
      |     ^~~~
xor.cpp:16:91: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   16 | #define file(name)  if (fopen(name".inp", "r")) { freopen(name".inp", "r", stdin); freopen(name".out", "w", stdout); freopen(name".bug", "w", stderr); }
      |                                                                                    ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
xor.cpp:82:5: note: in expansion of macro 'file'
   82 |     file(task);
      |     ^~~~
xor.cpp:16:125: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   16 | #define file(name)  if (fopen(name".inp", "r")) { freopen(name".inp", "r", stdin); freopen(name".out", "w", stdout); freopen(name".bug", "w", stderr); }
      |                                                                                                                      ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
xor.cpp:82:5: note: in expansion of macro 'file'
   82 |     file(task);
      |     ^~~~
xor.cpp:16:58: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   16 | #define file(name)  if (fopen(name".inp", "r")) { freopen(name".inp", "r", stdin); freopen(name".out", "w", stdout); freopen(name".bug", "w", stderr); }
      |                                                   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
xor.cpp:83:5: note: in expansion of macro 'file'
   83 |     file(tsk);
      |     ^~~~
xor.cpp:16:91: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   16 | #define file(name)  if (fopen(name".inp", "r")) { freopen(name".inp", "r", stdin); freopen(name".out", "w", stdout); freopen(name".bug", "w", stderr); }
      |                                                                                    ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
xor.cpp:83:5: note: in expansion of macro 'file'
   83 |     file(tsk);
      |     ^~~~
xor.cpp:16:125: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   16 | #define file(name)  if (fopen(name".inp", "r")) { freopen(name".inp", "r", stdin); freopen(name".out", "w", stdout); freopen(name".bug", "w", stderr); }
      |                                                                                                                      ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
xor.cpp:83:5: note: in expansion of macro 'file'
   83 |     file(tsk);
      |     ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...