Submission #90059

#TimeUsernameProblemLanguageResultExecution timeMemory
90059YaroslaffXOR (IZhO12_xor)C++14
0 / 100
4 ms632 KiB
#include <bits/stdc++.h> #define pb push_back #define F first #define S second #define ll long long //#define int ll #define ld long double #define endl '\n' #define TIME 1.0*clock()/CLOCKS_PER_SEC using namespace std; mt19937 gen(chrono::system_clock::now().time_since_epoch().count()); const int M = 1e9 + 7; const int FFTM = 998244353; const int N = 2e5 + 7; int n, a[N], x; pair<int,int> f(int l){ pair<int,int> res; int cur = 0; for (int i = 0; i < l; i++) cur ^= a[i]; if (cur >= x) return {1, 1}; for (int i = l; i < n; i++){ cur ^= a[i - l], cur ^= a[i]; if (cur >= x) return {1, i - l + 2}; } return {0, 0}; } main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); #ifdef LOCAL freopen("input.txt","r",stdin); freopen("output.txt","w",stdout); #else freopen("c.in","r",stdin); freopen("c.out","w",stdout); #endif cin >> n >> x; for (int i = 0; i < n; i++) cin >> a[i]; int l = 0, r = n, res = 0; while (l <= r){ int m = (l + r)>>1; if (f(m).F){ res = max(res, m); l = m + 1; } else r = m - 1; } cout << f(res).S << ' ' << res; return 0; }

Compilation message (stderr)

xor.cpp:35:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main() {
      ^
xor.cpp: In function 'int main()':
xor.cpp:43:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
     freopen("c.in","r",stdin);
     ~~~~~~~^~~~~~~~~~~~~~~~~~
xor.cpp:44:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
     freopen("c.out","w",stdout);
     ~~~~~~~^~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...