QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#88771#4810. Add OneOlegpresnyakovWA 2ms3480kbC++142.1kb2023-03-17 09:37:042023-03-17 09:37:06

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-03-17 09:37:06]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:3480kb
  • [2023-03-17 09:37:04]
  • 提交

answer

#pragma GCC optimize("Ofast")
#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <fstream>
#include<time.h>
#include <unordered_map>
#include <cstdlib>
#include <string.h>
#include <bitset>
#include <unordered_set>
#include <cstdlib>
#include <cassert>
#include <queue>

#define rep(i, n) for(int i = 0; i < (n); ++i)
#define rep1(i, n) for(int i = 1; i < (n); ++i)
#define rep1n(i, n) for(int i = 1; i <= (n); ++i)
#define repr(i, n) for(int i = (n) - 1; i >= 0; --i)
#define pb push_back
#define eb emplace_back
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define sz(a) (int)(a.size())
#define each(x, a) for(auto &x : a)
#define ar array
 
using namespace std;
 
int Bit(int mask, int b) { return (mask >> b) & 1ll; }
 
template<class T> bool ckmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
 
template<class T> bool ckmax(T &a, const T &b) {
    if (b > a) {
        a = b;
        return true;
    }
    return false;
}

//__builtin_popcount = int
//__builtin_popcountl = long int
//__builtin_popcountll = long long

void solve(){
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; ++i){
        cin >> a[i];
    }

    vector<int> b(61, 0);
    for(int i = 0; i < n; ++i){
        for(int bit = 0; bit < 61; ++bit){
            if(Bit(a[i], bit)){
                b[bit]++;
            }
        }
    }

    int index = -1;
    for(int i = 0; i < 61; ++i){
        if(b[i] == 0){
            index = i;
            break;
        }
    }

    for(int i = 0; i < index; ++i){
        b[i]--;
    }

    b[index]++;

    int ans = 0;
    for(int i = 0; i < 61; ++i){
        ans += ((1ll << i) * (b[i] % 2));
    }

    cout << ans << "\n";
}   

signed main(){
    ios_base::sync_with_stdio(0);
    cout.tie(0);
    cin.tie(0);

    int t = 1;
    //cin >> t;
    while(t--) {
        solve();
    }
}

詳細信息

Test #1:

score: 100
Accepted
time: 2ms
memory: 3324kb

input:

4
1 2 1 2

output:

7

result:

ok 1 number(s): "7"

Test #2:

score: 0
Accepted
time: 2ms
memory: 3476kb

input:

5
1 2 3 4 5

output:

14

result:

ok 1 number(s): "14"

Test #3:

score: 0
Accepted
time: 1ms
memory: 3328kb

input:

6
1 2 4 7 15 31

output:

47

result:

ok 1 number(s): "47"

Test #4:

score: 0
Accepted
time: 1ms
memory: 3388kb

input:

5
41 40 50 11 36

output:

99

result:

ok 1 number(s): "99"

Test #5:

score: 0
Accepted
time: 0ms
memory: 3472kb

input:

6
10 40 60 2 44 47

output:

96

result:

ok 1 number(s): "96"

Test #6:

score: 0
Accepted
time: 2ms
memory: 3476kb

input:

6
46 25 39 47 23 60

output:

107

result:

ok 1 number(s): "107"

Test #7:

score: -100
Wrong Answer
time: 2ms
memory: 3480kb

input:

6
56 90 61 63 56 23

output:

176

result:

wrong answer 1st numbers differ - expected: '112', found: '176'