QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#140639 | #4810. Add One | Williams | WA | 1ms | 3632kb | C++14 | 2.4kb | 2023-08-16 15:08:07 | 2023-08-16 15:08:11 |
Judging History
answer
#include <bits/stdc++.h>
#define for_(i,a,b) for (int i = (a); i < (b); i++)
#define rep_(i,a,b) for (int i = (a); i <= (b); i++)
#define per_(i,a,b) for (int i = (a); i >= (b); i--)
#define pii pair<int, int>
#define pll pair<ll, ll>
#define fi first
#define se second
#define ll long long
#define sz(a) (int)a.size()
#define all(v) v.begin(), v.end()
#define clr(x) memset(x, 0, sizeof(x))
#define wls(v) sort(all(v)); v.erase(unique(all(v)), v.end());
#define ull unsigned long long
#define pb push_back
#define D(x) cerr << #x << '=' << x << endl
#define outarr(a,L,R) cerr<<#a"["<<L<<".."<<R<<"]=";rep_(_x,(L),(R))cerr<<a[_x]<<" "; cerr<<endl;
#ifdef LOCAL
#define line cout << "--------------------------------" << endl;
#define CE cout << endl;
#define CO cout << "OK" << endl;
#endif
#define endl '\n'
#define int ll
using namespace std;
bool be;clock_t startTime;
double getCurrentTime() {
return (double)(clock() - startTime) / CLOCKS_PER_SEC;
}
const int maxn = 1e6 + 10, mod = 998244353;// mod = 1949777;
const double EPS = 1e-3;
template <typename Type>
void add(Type &x, Type y, Type Md) {
x += y; while(x >= Md) x -= Md;
while(x < 0) x += Md;
}
int n, m;
ll a[maxn];
bool ed;
void solve() {
}
ll t[100];
void ins(int x) {
rep_(i, 0, 60) {
if (x >> i & 1) {
if (!t[i]) {
t[i] = x;
break;
}
x ^= t[i];
}
}
return;
}
int check(int i) {
int msk = (1LL<<i+1)-1;
rep_(i, 0, 60) {
if (msk >> i & 1) {
if (!t[i]) return 0;
msk ^= t[i];
}
}
return 1;
}
signed main() {
#ifdef LOCAL
freopen("w.in", "r", stdin);
// freopen("w.out", "w", stdout);
startTime = clock();
// time_t now_time = time(NULL); tm* TuT = localtime(&now_time); cout << asctime(TuT); cout << "CodeBegin:_______________________" << endl;
// cout << "Memory footprint:" << ((&be - &ed) >> 20) <<"MB"<< endl;
// line;
#endif
ios::sync_with_stdio(false);
cin.tie(nullptr);
//int tt; cin >> tt; while(tt--) solve();
cin>> n;
ll s = 0;
rep_(i,1, n) {
cin >> a[i];
ins(a[i]);
s ^= a[i];
}
ll ans = 0;
ll now = 0;
rep_(i, 0, 60){
now ^= t[i];
ans = max(ans, s ^ now ^ (now + 1));
if (check(i)) ans = max(ans, s ^ ((1LL<<i+2)-1));
}
// CE
cout << ans << endl;
#ifdef LOCAL
cerr<<"\n\n-----------------------\nProgram done in "<<clock()-startTime<<" ms";
#endif
return 0;
}
//by whc
// check if over int , and open long long !!!
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3460kb
input:
4 1 2 1 2
output:
7
result:
ok 1 number(s): "7"
Test #2:
score: 0
Accepted
time: 0ms
memory: 3408kb
input:
5 1 2 3 4 5
output:
14
result:
ok 1 number(s): "14"
Test #3:
score: 0
Accepted
time: 1ms
memory: 3596kb
input:
6 1 2 4 7 15 31
output:
47
result:
ok 1 number(s): "47"
Test #4:
score: 0
Accepted
time: 1ms
memory: 3420kb
input:
5 41 40 50 11 36
output:
99
result:
ok 1 number(s): "99"
Test #5:
score: 0
Accepted
time: 1ms
memory: 3528kb
input:
6 10 40 60 2 44 47
output:
96
result:
ok 1 number(s): "96"
Test #6:
score: 0
Accepted
time: 1ms
memory: 3632kb
input:
6 46 25 39 47 23 60
output:
107
result:
ok 1 number(s): "107"
Test #7:
score: 0
Accepted
time: 0ms
memory: 3468kb
input:
6 56 90 61 63 56 23
output:
112
result:
ok 1 number(s): "112"
Test #8:
score: 0
Accepted
time: 1ms
memory: 3584kb
input:
7 8 83 78 19 36 6 22
output:
205
result:
ok 1 number(s): "205"
Test #9:
score: 0
Accepted
time: 1ms
memory: 3376kb
input:
7 23 23 22 78 2 29 88
output:
32
result:
ok 1 number(s): "32"
Test #10:
score: 0
Accepted
time: 1ms
memory: 3412kb
input:
7 109 80 14 27 9 45 24
output:
235
result:
ok 1 number(s): "235"
Test #11:
score: 0
Accepted
time: 1ms
memory: 3420kb
input:
7 144 152 137 143 145 139 183
output:
220
result:
ok 1 number(s): "220"
Test #12:
score: 0
Accepted
time: 1ms
memory: 3580kb
input:
7 189 270 119 372 240 144 153
output:
78
result:
ok 1 number(s): "78"
Test #13:
score: -100
Wrong Answer
time: 1ms
memory: 3380kb
input:
7 4819 2494 1822 4759 2622 4111 2460
output:
7502
result:
wrong answer 1st numbers differ - expected: '7510', found: '7502'