QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#715301 | #4810. Add One | SkyMaths | WA | 0ms | 3692kb | C++20 | 2.1kb | 2024-11-06 11:23:46 | 2024-11-06 11:23:47 |
Judging History
answer
#include<bits/stdc++.h>
#define rep(i,l,r) for (int i(l), i##end(r); i <= i##end; ++i)
#define per(i,r,l) for (int i(r), i##end(l); i >= i##end; --i)
#define ll long long
#define ull unsigned long long
#define fi first
#define se second
#define eb emplace_back
#define File(filename) freopen(filename".in", "r", stdin), freopen(filename".out", "w", stdout)
using namespace std;
template <typename Tx> inline void read(Tx &x) {x = 0; bool f = 0; char ch = getchar(); while (ch < '0' || ch > '9') f ^= ch == '-', ch = getchar(); while (ch <= '9' && ch >= '0') x = x * 10 + ch - '0', ch = getchar(); if (f) x = -x;}
template <typename Tx, typename ...Ty> inline void read(Tx &x, Ty &...y) {read(x); read(y...);}
template <typename Tx> inline void O_write(Tx x) {if (x > 9) O_write(x / 10); putchar('0' + x % 10);}
template <typename Tx> inline void write(Tx x, char ch = '\n') {O_write(x < 0 ? (putchar('-'), -x) : x); putchar(ch);}
template <typename Tx> inline void cmax(Tx &x, Tx y) {if (x < y) x = y;}
template <typename Tx> inline void cmin(Tx &x, Tx y) {if (x > y) x = y;}
namespace Main {
const int N = 1e6 + 9;
const int LogW = 60;
int n;
ull p[LogW + 1], ans;
bool chk(ull x) {
per (i, LogW, 0) if (x >> i & 1) {
x ^= p[i];
}
return x == 0 ? 1 : 0;
}
void upd(ull x) {
per (j, LogW, 0) if (x >> j & 1) {
if (p[j]) x ^= p[j];
else {
p[j] = x;
break;
}
}
}
void skymaths() {
read(n);
rep (i, 1, n) { ull x;
read(x);
ans ^= x;
upd(x);
}
per (i, LogW, 0) {
if (chk((1ll << i) - 1)) {
ans ^= (1ll << i + 1) - 1;
write(ans);
return ;
}
else {
if (p[i]) {
ull x = p[i];
p[i] = x;
if (x) {
x ^= 1ll << i;
upd(x);
}
}
}
}
}
signed main() {
// freopen("a.in", "r", stdin);
int T = 1;
// read(T);
while (T--) {
skymaths();
}
return 0;
} } signed main() { Main::main(); return 0;}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3620kb
input:
4 1 2 1 2
output:
7
result:
ok 1 number(s): "7"
Test #2:
score: 0
Accepted
time: 0ms
memory: 3556kb
input:
5 1 2 3 4 5
output:
14
result:
ok 1 number(s): "14"
Test #3:
score: 0
Accepted
time: 0ms
memory: 3620kb
input:
6 1 2 4 7 15 31
output:
47
result:
ok 1 number(s): "47"
Test #4:
score: 0
Accepted
time: 0ms
memory: 3616kb
input:
5 41 40 50 11 36
output:
99
result:
ok 1 number(s): "99"
Test #5:
score: 0
Accepted
time: 0ms
memory: 3680kb
input:
6 10 40 60 2 44 47
output:
96
result:
ok 1 number(s): "96"
Test #6:
score: 0
Accepted
time: 0ms
memory: 3692kb
input:
6 46 25 39 47 23 60
output:
107
result:
ok 1 number(s): "107"
Test #7:
score: -100
Wrong Answer
time: 0ms
memory: 3684kb
input:
6 56 90 61 63 56 23
output:
48
result:
wrong answer 1st numbers differ - expected: '112', found: '48'