QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#26112#1830. ANDSorting#WA 2ms3500kbC++20888b2022-04-06 16:06:592022-04-29 02:57:30

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-04-29 02:57:30]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:3500kb
  • [2022-04-06 16:06:59]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
template<class T> void check_min(T &a, const T &b){ a = (a < b) ? a : b; }
template<class T> void check_max(T &a, const T &b){ a = (a > b) ? a : b; }
#define all(x) (x).begin(), (x).end()

int main(){
    ios::sync_with_stdio(false);
    cin.tie(NULL);

    int t;
    cin >> t;
    
    while(t--){
        int n;
        cin >> n;

        vector<int> b(n);
        for(int &x: b)
            cin >> x;
        sort(all(b));

        bool ok = true;
        for(int i = 1; i < n; ++i)
            if((b[i] & b[0]) != b[0])
                ok = false;

        if(!ok){
            cout << -1 << "\n";
            continue;
        }

        cout << b[0] << " ";
        for(int i = 1; i < n; ++i)
            cout << b[i] << " " << b[0] << " ";
        cout << "\n"; 
    }
}

詳細信息

Test #1:

score: 0
Wrong Answer
time: 2ms
memory: 3500kb

input:

3
1
5
3
0 1 2
2
1 2

output:

5 
0 1 0 2 0 
-1

result:

wrong answer set of ands are not equal (test case 1)