QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#526423#9176. Non-Interactive Nimucup-team1264WA 0ms3600kbC++201.5kb2024-08-21 15:39:122024-08-21 15:39:12

Judging History

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

  • [2024-08-21 15:39:12]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3600kb
  • [2024-08-21 15:39:12]
  • 提交

answer

// https://www.youtube.com/watch?v=wthasN45KuY
// You said I’d fly away
// But my walls have kept me down
// Now I’m lost and I’m afraid
// And I’m close to hit the ground
// 
// You said I’d fly away
// You said I’d fly anywhere
// But I keep on Falling

#ifndef ONLINE_JUDGE
#include "templates/debug.hpp"
#else
#define debug(...)
#endif

#include <bits/stdc++.h>
using namespace std;
using i64 = int64_t;
using u64 = uint64_t;

// #define int i64
void solve() {
    int n; cin >> n;
    vector<i64> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    vector<pair<int, i64>> ans;
    bool sat = true;
    for (int b = 59; b >= 0; b--) {
        int cnt = 0, x = -1, y = -1;
        for (int i = 0; i < n; i++) {
            if (a[i] >> b & 1) {
                cnt++;
                if (cnt == 1) x = i;
                else if (cnt == 2) y = i;
            }
        }
        if (cnt > 2) sat = false;
        if (cnt == 2) {
            ans.emplace_back(x, a[x]);
            a[y] ^= a[x]; a[x] = 0;
        }
    }
    if (sat) {
        cout << ans.size() << "\n";
        for (auto [i, x]: ans) {
            cout << i << " " << x << "\n";
        }
    } else {
        cout << -1 << "\n";
    }
}
#undef int

// Make bold hypotheses and verify carefully
int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int t = 1;
    cin >> t;
    while (t--) {
        solve();
    }
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3600kb

input:

2
4
4 2 7 1
4
1 1 1 1

output:

3
0 4
1 2
2 1
-1

result:

wrong answer Integer parameter [name=p] equals to 0, violates the range [1, 4] (test case 1)