QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#515354#9176. Non-Interactive Nimk1nsomWA 0ms3780kbC++171017b2024-08-11 17:18:162024-08-11 17:18:16

Judging History

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

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

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);
                break;
            }
    }
    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], a[pre[j][0]]});
    }
    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: 0
Wrong Answer
time: 0ms
memory: 3780kb

input:

2
4
4 2 7 1
4
1 1 1 1

output:

1
1 4
-1

result:

wrong answer game has not ended yet (test case 1)