QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#279475#6961. XOR SubsequenceIsaacMoris#WA 255ms6392kbC++141.6kb2023-12-08 19:43:172023-12-08 19:43:18

Judging History

你现在查看的是最新测评结果

  • [2023-12-08 19:43:18]
  • 评测
  • 测评结果:WA
  • 用时:255ms
  • 内存:6392kb
  • [2023-12-08 19:43:17]
  • 提交

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];
        cnt += add(a[i]);
    }
    if (cnt > n) {
        cout << -1 << "\n";
        return;
    }
    sort(a.begin(), a.end());
    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;
    }
    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();
    }
}

詳細信息

Test #1:

score: 0
Wrong Answer
time: 255ms
memory: 6392kb

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 
139004411 75752216 
425320853 1040767902 1033998872 
16842978 289669156 272894568 268438464 
288507119 764545802 704365180 383353160 678684512 
-1
0 0 0 67108864 134217728 268435456 536870912 
285628849 778291430 421594356 457230488 212099792 311457632 475515968 866106752 
1072053851 2334...

result:

wrong answer 2nd lines differ - expected: '75752216 139004411', found: '139004411 75752216 '