QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#526423 | #9176. Non-Interactive Nim | ucup-team1264 | WA | 0ms | 3600kb | C++20 | 1.5kb | 2024-08-21 15:39:12 | 2024-08-21 15:39:12 |
Judging History
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)