QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#549612 | #9176. Non-Interactive Nim | ucup-team3519# | WA | 38ms | 3832kb | C++23 | 1.0kb | 2024-09-06 18:44:55 | 2024-09-06 18:44:56 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define V vector
#define pb push_back
#define fi first
#define se second
#define all1(x) (x).begin() + 1, (x).end()
typedef pair<int, int> pi;
void solve() {
int n; cin >> n;
V<int> a(n + 1);
for(int i = 1; i <= n; i++) cin >> a[i];
if(n > 200) {
cout << -1 << endl;
return;
}
priority_queue<pi> pq;
for(int i = 1; i <= n; i++) {
pq.push({a[i], i});
}
V<pi> ans;
while(pq.size()) {
auto [x, xid] = pq.top();
pq.pop();
auto [y, yid] = pq.top();
pq.pop();
if(__lg(x) != __lg(y) || pq.size() && __lg(pq.top().fi) == __lg(x)) {
cout << -1 << endl;
return;
}
ans.pb({xid, (x - (x ^ y))});
if(x != y) pq.push({x ^ y, xid});
}
cout << ans.size() << endl;
for(auto [x, y] : ans) cout << x << " " << y << endl;
}
int main() {
ios::sync_with_stdio(0), cin.tie(0);
int t; cin >> t;
while(t--) solve();
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3660kb
input:
2 4 4 2 7 1 4 1 1 1 1
output:
3 3 4 3 2 4 1 -1
result:
ok OK 1 yes 1 no (2 test cases)
Test #2:
score: 0
Accepted
time: 38ms
memory: 3832kb
input:
50000 2 3 3 2 2 2 2 3 3 2 2 2 2 3 3 2 3 3 2 1 1 2 1 1 2 1 1 2 2 2 2 2 2 2 3 3 2 2 2 2 1 1 2 3 3 2 1 1 2 1 1 2 1 1 2 3 3 2 1 1 2 1 1 2 3 3 2 2 2 2 3 3 2 3 3 2 2 2 2 1 1 2 3 3 2 2 2 2 2 2 2 3 3 2 3 3 2 1 1 2 1 1 2 1 1 2 3 3 2 3 3 2 1 1 2 1 1 2 3 3 2 2 2 2 2 2 2 2 2 2 1 1 2 1 1 2 2 2 2 2 2 2 1 1 2 3 3 ...
output:
1 2 3 1 2 2 1 2 3 1 2 2 1 2 3 1 2 3 1 2 1 1 2 1 1 2 1 1 2 2 1 2 2 1 2 3 1 2 2 1 2 1 1 2 3 1 2 1 1 2 1 1 2 1 1 2 3 1 2 1 1 2 1 1 2 3 1 2 2 1 2 3 1 2 3 1 2 2 1 2 1 1 2 3 1 2 2 1 2 2 1 2 3 1 2 3 1 2 1 1 2 1 1 2 1 1 2 3 1 2 3 1 2 1 1 2 1 1 2 3 1 2 2 1 2 2 1 2 2 1 2 1 1 2 1 1 2 2 1 2 2 1 2 1 1 2 3 1 2 3 ...
result:
ok OK 50000 yes 0 no (50000 test cases)
Test #3:
score: -100
Wrong Answer
time: 32ms
memory: 3608kb
input:
50000 2 89846347117873058 89846347117873058 2 416235892302498917 416235892302498917 2 332154513003612985 332154513003612985 2 43960216631774959 43960216631774959 2 353215896487285554 353215896487285554 2 38296945667390613 38296945667390613 2 209150071115726640 209150071115726640 2 48610805835417777 ...
output:
-1 1 2 0 1 2 0 1 2 0 1 2 0 1 2 0 1 2 0 1 2 0 1 2 0 1 2 0 1 2 0 1 2 0 1 2 0 1 2 0 1 2 0 1 2 0 1 2 0 1 2 0 1 2 0 1 2 0 1 2 0 1 2 0 1 2 0 1 2 0 1 2 0 1 2 0 1 2 0 1 2 0 1 2 0 1 2 0 1 2 0 1 2 0 1 2 0 1 2 0 1 2 0 1 2 0 1 2 0 1 2 0 1 2 0 1 2 0 1 2 0 1 2 0 1 2 0 1 2 0 1 2 0 1 2 0 1 2 0 1 2 0 1 2 0 1 2 0 1 2...
result:
wrong answer judge has answer but participant doesn't (test case 1)