QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#512683 | #8823. Game: Battle of Menjis | algotester# | WA | 51ms | 4056kb | C++14 | 1.5kb | 2024-08-10 15:22:11 | 2024-08-10 15:22:12 |
Judging History
answer
#include "bits/stdc++.h"
// #include "algotester.h"
// #include "algotester_generator.h"
using namespace std;
#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define RFOR(i,b,a) for (int i = (b) - 1; i >= (a); i--)
#define ITER(it,a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a,value) memset(a, value, sizeof(a))
#define SZ(a) (int)a.size()
#define ALL(a) a.begin(), a.end()
#define PB push_back
#define MP make_pair
typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PII;
const double PI = acos(-1.0);
const int INF = 1000 * 1000 * 1000 + 7;
const LL LINF = INF * (LL) INF;
const int LEN = 31;
int get_zeros(int x)
{
if (x == 0) return -1;
int res = 0;
while(x % 2 == 0)
{
x /= 2;
res++;
}
return res;
}
void solve_test()
{
int n, k;
scanf("%d%d", &n, &k);
VI a;
FOR (i, 0, n)
{
int x;
scanf("%d", &x);
a.PB(x);
}
vector<VI> p(LEN);
FOR (i, 0, n)
{
int x = get_zeros(a[i]);
if (x != -1) p[x].PB(a[i]);
}
int s = 0;
FOR (i, 0, n)
{
s ^= a[i];
}
int res = 0;
FOR (it, 0, n)
{
int cur_res = s;
s ^= a[it];
s ^= a[it] + 1;
FOR (i, 0, LEN)
{
if ((s & (1<<i)) == 0) continue;
if ((SZ(p[i]) > 1) || ((SZ(p[i]) == 1) && p[i][0] != a[it]))
{
int cur = s ^ ((1<<(i+1)) - 1);
cur_res = min(cur_res, cur);
}
}
s ^= a[it];
s ^= a[it] + 1;
res = max(res, cur_res);
}
printf("%d\n", res);
}
int main(int argc, char* argv[])
{
//ios::sync_with_stdio(false); cin.tie(0);
int tt;
scanf("%d", &tt);
for (;tt;tt--)
{
solve_test();
}
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3772kb
input:
4 2 3 1 1 4 4 0 0 0 0 4 1 1 2 4 8 13 5 1 1 4 5 1 4 1 9 1 9 8 1 0
output:
0 0 9 11
result:
ok 4 number(s): "0 0 9 11"
Test #2:
score: -100
Wrong Answer
time: 51ms
memory: 4056kb
input:
100000 1 5 0 4 5 4 4 3 5 5 2 0 1 7 5 4 4 1 6 4 4 4 1 5 3 2 2 1 1 3 1 5 4 0 2 4 0 3 2 2 1 7 3 1 2 1 6 2 4 5 1 3 1 3 7 0 4 4 7 5 4 4 3 3 1 1 5 1 3 3 3 2 3 7 4 4 1 3 1 0 5 5 3 6 2 3 6 3 3 1 2 6 6 4 4 5 4 1 3 2 1 4 4 4 5 0 1 6 5 4 5 0 7 7 5 2 4 4 0 5 1 7 0 2 6 0 3 4 5 2 3 2 3 4 3 3 2 1 0 1 2 2 6 5 5 1 6...
output:
0 2 7 2 3 0 1 3 6 5 4 4 2 5 3 0 7 2 0 3 0 2 5 4 3 4 7 0 3 2 4 4 4 2 4 6 1 3 2 7 4 7 4 6 2 4 4 3 7 0 2 2 1 0 6 7 0 0 1 7 1 3 3 6 2 1 5 5 5 1 6 4 1 2 0 7 1 4 3 6 7 7 0 1 7 0 0 4 0 4 7 7 7 4 6 2 5 4 7 4 1 6 4 4 3 4 7 5 4 4 3 6 1 2 5 4 2 1 1 0 0 0 0 6 1 3 4 0 1 4 6 3 1 3 5 1 0 6 3 2 1 4 5 2 1 2 2 7 6 7 ...
result:
wrong answer 212th numbers differ - expected: '5', found: '7'