QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#515344#9176. Non-Interactive Nimk1nsomWA 260ms3604kbC++17957b2024-08-11 17:16:112024-08-11 17:16:11

Judging History

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

  • [2024-08-11 17:16:11]
  • 评测
  • 测评结果:WA
  • 用时:260ms
  • 内存:3604kb
  • [2024-08-11 17:16:11]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
#define PII pair<int, int>
const int N = 2e5 + 5;
const int mod = 1e9 + 7;
int n, a[N];
void solve()
{
    cin >> n;
    vector<vector<int>> pre(65);
    for (int i = 1; i <= n; i++)
    {
        cin >> a[i];
        for (int j = 60; j >= 0; j--)
            if (a[i] & (1ll << j))
                pre[j].push_back(i);
    }
    vector<PII> ans;
    for (int j = 60; j >= 0; j--)
    {
        if (pre[j].size() > 2)
        {
            cout << -1 << endl;
            return;
        }
        else if (pre[j].size() == 2)
            ans.push_back({pre[j][0], 1 << j});
    }
    cout << ans.size() << endl;
    for (auto [x, y] : ans)
        cout << x << ' ' << y << endl;
}
signed main()
{
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int t = 1;
    cin >> t;
    while (t--)
        solve();
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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: 24ms
memory: 3584kb

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:

2
1 2
1 1
1
1 2
2
1 2
1 1
1
1 2
2
1 2
1 1
2
1 2
1 1
1
1 1
1
1 1
1
1 1
1
1 2
1
1 2
2
1 2
1 1
1
1 2
1
1 1
2
1 2
1 1
1
1 1
1
1 1
1
1 1
2
1 2
1 1
1
1 1
1
1 1
2
1 2
1 1
1
1 2
2
1 2
1 1
2
1 2
1 1
1
1 2
1
1 1
2
1 2
1 1
1
1 2
1
1 2
2
1 2
1 1
2
1 2
1 1
1
1 1
1
1 1
1
1 1
2
1 2
1 1
2
1 2
1 1
1
1 1
1
1 1
2
1 2
...

result:

ok OK 50000 yes 0 no (50000 test cases)

Test #3:

score: -100
Wrong Answer
time: 260ms
memory: 3544kb

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:

30
1 16777216
1 2097152
1 1048576
1 524288
1 262144
1 131072
1 65536
1 8192
1 4096
1 512
1 128
1 64
1 4
1 2
1 -2147483648
1 1073741824
1 268435456
1 67108864
1 4194304
1 1048576
1 131072
1 65536
1 32768
1 16384
1 1024
1 512
1 256
1 128
1 32
1 2
31
1 67108864
1 16777216
1 8388608
1 4194304
1 262144
1...

result:

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