QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#599280#9176. Non-Interactive NimfosovWA 31ms3656kbC++141.3kb2024-09-29 03:00:112024-09-29 03:00:11

Judging History

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

  • [2024-09-29 03:00:11]
  • 评测
  • 测评结果:WA
  • 用时:31ms
  • 内存:3656kb
  • [2024-09-29 03:00:11]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;

using ll = long long;

#define INF 0x3f3f3f3f
#define LNF (ll) 0x3f3f3f3f3f3f3f3f 

#define MOD 998244353
#define N 220

int main() {
#ifdef TEST
    freopen("zz.in", "r+", stdin);
#endif
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);    

    int t; cin >> t;
    while (t --) {
        int n; cin >> n;
        vector<ll> a(n);
        for (int i = 0; i < n; ++ i) cin >> a[i];
        
        vector<pair<int, int>> moves;
        bool possible = 1;
        for (int k = 60; k >= 0; -- k) {
            vector<int> s;
            for (int i = 0; i < n; ++ i) {
                if ((a[i] >> k) & 1) s.emplace_back(i);
            }
            
            if (s.empty()) continue;
            if (s.size() != 2) {
                possible = 0;
                break;
            }
            moves.emplace_back(s[0]+1, a[s[0]]);
            a[s[1]] ^= a[s[0]];
            a[s[0]] = 0;
        } 

        for (int i = 0; i < n; ++ i) possible &= !a[i];
        
        if (!possible) {
            cout << -1 << '\n';
        } else {
            cout << moves.size() << '\n';
            for (auto [p, x] : moves) cout << p << ' ' << x << '\n';
        }
    }
}   

詳細信息

Test #1:

score: 100
Accepted
time: 0ms
memory: 3508kb

input:

2
4
4 2 7 1
4
1 1 1 1

output:

3
1 4
2 2
3 1
-1

result:

ok OK 1 yes 1 no (2 test cases)

Test #2:

score: 0
Accepted
time: 20ms
memory: 3656kb

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
1 3
1
1 2
1
1 3
1
1 2
1
1 3
1
1 3
1
1 1
1
1 1
1
1 1
1
1 2
1
1 2
1
1 3
1
1 2
1
1 1
1
1 3
1
1 1
1
1 1
1
1 1
1
1 3
1
1 1
1
1 1
1
1 3
1
1 2
1
1 3
1
1 3
1
1 2
1
1 1
1
1 3
1
1 2
1
1 2
1
1 3
1
1 3
1
1 1
1
1 1
1
1 1
1
1 3
1
1 3
1
1 1
1
1 1
1
1 3
1
1 2
1
1 2
1
1 2
1
1 1
1
1 1
1
1 2
1
1 2
1
1 1
1
1 3
1
1 3
...

result:

ok OK 50000 yes 0 no (50000 test cases)

Test #3:

score: -100
Wrong Answer
time: 31ms
memory: 3568kb

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 -732706910
1
1 -1217049499
1
1 236948281
1
1 -2003431697
1
1 -2027597006
1
1 -2105754475
1
1 -1382432976
1
1 907069617
1
1 -1590423279
1
1 -184398503
1
1 1362194955
1
1 -538128596
1
1 -1851726319
1
1 1712060750
1
1 1654165883
1
1 -1342859856
1
1 -1453378331
1
1 401622420
1
1 -664206506
1
1 -2108...

result:

wrong answer Integer parameter [name=x] equals to -732706910, violates the range [1, 89846347117873058] (test case 1)