#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define f first
#define s second
#define pii pair<ll, ll>
#define REP(i,n) for (int i = 0; i<n; ++i)
#define REP1(i,n) for (int i = 1; i<=n; ++i)
#define MX(a,b) a = max(a,b)
#define MN(a,b) a = min(a,b)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) (int)((x).size())
#define pb push_back
#ifdef BALBIT
#define bug(...) cerr<<"#"<<__LINE__<<": "<<#__VA_ARGS__<<"- ", _do(__VA_ARGS__)
template<typename T> void _do( T && x) {cerr<<x<<endl;}
template<typename T, typename ...S> void _do( T && x, S && ...y) {cerr<<x<<", "; _do(y...);}
#else
#define bug(...)
#define endl '\n'
#endif // BALBIT
signed main(){
ios::sync_with_stdio(0), cin.tie(0);
int t; cin>>t;
while (t--) {
int n,k; cin>>n>>k;
vector<int> a(n);
int x = 0;
REP(i,n) {
cin>>a[i]; x ^= a[i];
}
if( k == 0) {
cout<<0<<endl;
assert(0);
continue;
}
int lbit = x&-x;
if (k >= lbit && lbit != 0) {
cout<<1;
}else{
// now think...
// guess: only do k= 2^P ????
for (int e : a) {
for (int ar = 1; ar <= k && ar <= e; ar*=2) {
int xx = x ^ e ^ (e-ar);
int lb = xx & -xx;
if (ar < lb) {
assert(0);
cout<<1;
goto done;
}
}
}
cout<<0;
}
done:;
}
cout<<endl;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
11 ms |
332 KB |
Output is correct |
2 |
Correct |
10 ms |
332 KB |
Output is correct |
3 |
Correct |
11 ms |
392 KB |
Output is correct |
4 |
Correct |
13 ms |
332 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
0 ms |
316 KB |
Output is correct |
4 |
Correct |
0 ms |
204 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
8 ms |
332 KB |
Output is correct |
2 |
Correct |
7 ms |
460 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
21 ms |
332 KB |
Output is correct |
2 |
Correct |
22 ms |
360 KB |
Output is correct |
3 |
Correct |
22 ms |
364 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
33 ms |
356 KB |
Output is correct |
2 |
Correct |
31 ms |
360 KB |
Output is correct |
3 |
Correct |
30 ms |
388 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
10 ms |
332 KB |
Output is correct |
2 |
Correct |
9 ms |
332 KB |
Output is correct |
3 |
Correct |
10 ms |
332 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
12 ms |
396 KB |
Output is correct |
2 |
Correct |
10 ms |
1260 KB |
Output is correct |
3 |
Correct |
11 ms |
1348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
11 ms |
332 KB |
Output is correct |
2 |
Correct |
14 ms |
1272 KB |
Output is correct |