# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
67973 | 2018-08-15T16:13:44 Z | cdemirer | XOR Sum (info1cup17_xorsum) | C++17 | 1600 ms | 24592 KB |
#include <bits/stdc++.h> #include <limits> using namespace std; typedef long long ll; typedef pair<int, int> ii; typedef vector<int> vi; typedef vector<vi> vvi; typedef vector<ii> vii; typedef vector<vii> vvii; typedef pair<double, double> dodo; typedef pair<ll, ll> llp; #define mp(x, y) make_pair(x, y) #define pb(x) push_back(x) ll N; vector<ll> A; ll ans[31] = {0}; int main(int argc, char **argv) { ios_base::sync_with_stdio(0); cin.tie(0); cin >> N; A.resize(N); for (int i = 0; i < N; i++) cin >> A[i]; for (ll k = 0; k < 31; k++) { vector<ll> B; for (int i = 0; i < A.size(); i++) if (!(A[i] & (1<<k))) B.pb(A[i]); for (int i = 0; i < A.size(); i++) if ((A[i] & (1<<k))) B.pb(A[i]); A = B; llp limits = mp(1<<k, 1<<(k+1)); llp range = mp(N-1, N-1); for (int i = 0; i < N; i++) { while (range.first >= 0 && A[range.first]%(1<<(k+1)) + A[i]%(1<<(k+1)) > limits.first) range.first--; while (range.second >= 0 && A[range.second]%(1<<(k+1)) + A[i]%(1<<(k+1)) > limits.second) range.second--; ans[k] += range.second - range.first; } ll limit = (1<<(k+1)) + (1<<k); range = mp(N-1, N-1); for (int i = 0; i < N; i++) { while (range.first >= 0 && A[range.first]%(1<<(k+1)) + A[i]%(1<<(k+1)) > limit) range.first--; ans[k] += range.second - range.first; } } ll out = 0; for (int k = 0; k < 31; k++) { out |= ((ans[k]%2)<<k); } cout << out << endl; return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 28 ms | 504 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1655 ms | 24592 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1655 ms | 24592 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 28 ms | 504 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 28 ms | 504 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |