QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#279476 | #6961. XOR Subsequence | IsaacMoris# | WA | 203ms | 6508kb | C++14 | 1.7kb | 2023-12-08 19:45:55 | 2023-12-08 19:45:55 |
Judging History
answer
#include<iostream>
#include <bits/stdc++.h>
#define ld long double
#define ll long long
#define IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
const int N = 30, mod = 998244353;
int basis[N];
bool add(int mask) {
for (int i = 0; i < N; i++) {
if ((mask & 1 << i) == 0)continue;
if (!basis[i]) {
basis[i] = mask;
return true;
}
mask ^= basis[i];
}
return false;
}
vector<int> query(vector<int> &ans) {
vector<int> res;
int n = ans.size();
for (int mask = 0; mask < (1 << n); mask++) {
int cur = 0;
for (int i = 0; i < n; i++) {
if ((mask & 1 << i) != 0) {
cur ^= ans[i];
}
}
res.push_back(cur);
}
sort(res.begin(), res.end());
return res;
}
void doWork() {
memset(basis, 0, sizeof basis);
int n;
cin >> n;
int cnt = 0;
vector<int> a(1 << n, 0);
for (int i = 1; i < (1 << n); i++) {
cin >> a[i];
}
sort(a.begin(), a.end());
for (auto i: a) {
cnt += add(i);
}
if (cnt > n) {
cout << -1 << "\n";
return;
}
vector<int> ans(n - cnt, 0);
for (int i = 0; i < N; i++) {
if (basis[i]) {
ans.push_back(basis[i]);
}
}
if (a != query(ans)) {
cout << "-1\n";
return;
}
sort(ans.begin(), ans.end());
for (auto i: ans)cout << i << " ";
cout << "\n";
}
int main() {
IO
int t = 1;
cin >> t;
for (int i = 1; i <= t; i++) {
// cout << "Case #" << i << ": ";
doWork();
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 203ms
memory: 6508kb
input:
4115 1 220426753 2 75752216 139004411 214624995 3 425320853 659634699 1040767902 61426054 620262285 1033998872 451979283 4 289669156 16842978 272957638 16779852 289737354 21236708 4456872 268501358 285213068 272894568 4524806 21299530 68270 285281058 268438464 5 288507119 704365180 764545802 9869220...
output:
220426753 75752216 139004411 61426054 425320853 1033998872 68270 4456872 16779852 268438464 25699612 34220493 74041718 383353160 678684512 -1 0 0 0 67108864 134217728 268435456 536870912 136604 6052763 27897018 40098288 91544872 247970592 475515968 866106752 2026397 2791316 9984104 17803262 6...
result:
wrong answer 3rd lines differ - expected: '61426054 425320853 620262285', found: '61426054 425320853 1033998872 '