QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#549612#9176. Non-Interactive Nimucup-team3519#WA 38ms3832kbC++231.0kb2024-09-06 18:44:552024-09-06 18:44:56

Judging History

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

  • [2024-09-06 18:44:56]
  • 评测
  • 测评结果:WA
  • 用时:38ms
  • 内存:3832kb
  • [2024-09-06 18:44:55]
  • 提交

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)