Submission #1104097

#TimeUsernameProblemLanguageResultExecution timeMemory
1104097vjudge1XOR (IZhO12_xor)C++17
0 / 100
1 ms336 KiB
// بسم الله الرحمن الرحيم // All praise is due to ALLAH alone #include<bits/stdc++.h> using namespace std; #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace __gnu_pbds; #define endl '\n' #define exit return 0 #define ll long long int #define ull unsigned long long int #define read freopen ("input.txt","r",stdin); #define write freopen ("output.txt","w",stdout); #define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); #define print_vec(vec) for(int i=0;i<vec.size();i++){cout<<vec[i]<<' ';}cout<<"\n"; #define print_set(st) for(auto it=st.begin();it!=st.end();it++){cout<<*it<<' ';}cout<<"\n"; typedef tree<ll, null_type, less_equal<ll>, rb_tree_tag, tree_order_statistics_node_update>ordered_set; #define print_pair(vec) for(int i=0;i<vec.size();i++)cout<<vec[i].first<<' '<<vec[i].second<<endl; #define dbg(num) cerr<< "Line "<<__LINE__ <<": "<< #num <<" = "<<(num)<<endl // find_by_order() and order_of_key() // k-th sorted element and lower_bound //priority_queue <int, vector<int>, greater<int> > pq; **non_decreasing //int dx[] = { -2, -2, -1, -1, 1, 1, 2, 2}; //int dy[] = { -1, 1, -2, 2, -2, 2, -1, 1}; ll lcm (ll a, ll b) {return a * (b / __gcd(a, b));} int dx[] = { -1, 0, +1, 0}; int dy[] = {0, +1, 0, -1}; #define sz 200001 #define mod 1000000007 void solve() { ll n, x; cin >> n >> x; ll arr[n + 1]; vector<ll>prefix(n + 1, 0); ll curr = 0; for (int i = 1; i <= n; i++) cin >> arr[i], curr ^= arr[i], prefix[i] = curr; int low = 1, high = n, mid, res = 0, start; while (low <= high) { mid = (low + high) / 2; int left = 1, right = mid; int found = 0; while (right <= n) { ll curr_xor = prefix[right] ^ prefix[left - 1]; if (curr_xor >= x) start = left, found = 1; left++, right++; } if (found) res = mid, low = mid + 1; else high = mid - 1; } cout << start << ' ' << res << endl; } int main() { fast; int tc = 1; //cin >> tc; while (tc--) solve(); //.............................................. ٱلْحَمْدُ لِلَّٰ...................................... }

Compilation message (stderr)

xor.cpp: In function 'void solve()':
xor.cpp:56:19: warning: 'start' may be used uninitialized in this function [-Wmaybe-uninitialized]
   56 |  cout << start << ' ' << res << endl;
      |                   ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...