QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#705898#7932. AND-OR closureohiostatescarlet#WA 0ms3644kbC++171.5kb2024-11-03 03:44:052024-11-03 03:44:06

Judging History

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

  • [2024-11-03 03:44:06]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3644kb
  • [2024-11-03 03:44:05]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define ll long long
ll BIT = 40;
vector<int> component;
int find(int x) {
    return (component[x] < 0) ? x : (component[x] = find(component[x]));
}
bool join(int x, int y) {
    x = find(x);
    y = find(y);
    if (x == y) return false;
    if (component[x] > component[y]) swap(x,y);
    component[x] += component[y];
    component[y] = x;
    return true;
}

int main() {
    cin.tie(0)->sync_with_stdio(0);
    cin.exceptions(cin.failbit);
    int n; cin >> n;
    bool hasZero = false;
    vector<ll> vals(n, 0);
    component.assign(BIT, -1);
    vector<vector<bool>> edges(BIT, vector<bool>(BIT, false));
    ll scl = 2;
    ll msk = 0;
    for (int i = 0; i < n; i++) {
        ll v; cin >> v;
        vals[i] = v;
        if (v == 0) hasZero = true;
        vector<int> unset;
        vector<int> set;
        for (int j = 0; j < BIT; j++) {
            if ((v>>j)&1) {
                set.push_back(j);
            } else {
                unset.push_back(j);
            }
        }
        for (int a : set) for (int b : unset) {
            edges[a][b] = true;
            if (edges[b][a]) {
                if (join(a,b)) {
                    scl *= 2;
                    msk |= (1ll << a) | (1ll << b);
                }
            }
        }
    }
    ll res = scl - 1;
    for (ll v : vals) {
        if ((v&msk) == 0) {
            res++;
        }
    }
    cout << res << "\n";
}

詳細信息

Test #1:

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

input:

4
0 1 3 5

output:

5

result:

ok 1 number(s): "5"

Test #2:

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

input:

5
0 1 2 3 4

output:

8

result:

ok 1 number(s): "8"

Test #3:

score: -100
Wrong Answer
time: 0ms
memory: 3584kb

input:

49
1097363587067 1096810445814 275012137504 1096739142630 1096809921522 1087071335264 829364908576 949625500192 1087142638448 1096200190829 1097292808175 1095750860656 1087144145776 1097346808827 1095734082416 1096755396578 829230678048 1095663303524 1087072842592 1096216444777 949623992864 10962714...

output:

68719476736

result:

wrong answer 1st numbers differ - expected: '52', found: '68719476736'