QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#346900#7932. AND-OR closurekevinshan#WA 1ms3688kbC++172.4kb2024-03-09 06:09:322024-03-09 06:09:34

Judging History

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

  • [2024-03-09 06:09:34]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3688kb
  • [2024-03-09 06:09:32]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define all(x) x.begin(), x.end()
#define pb push_back
#define f first
#define s second

#define FOR(i,a,b) for(int i=a;i<b;i++) 
#define For(i,a) FOR(i,0,a)
#define trav(a,b) for(auto& a:b)
#define pi pair<int,int>
#define vi vector<int>
#define vl vector<ll>

const int MX = 2e5+5;
const int MOD = 1e9+7;
const ll INF = 1e18;

ll a[MX];
set<int> reps[40];
bool done[40];
vi todo[42];
ll ans[44];

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    if (fopen("input.in", "r")) {
        freopen("input.in", "r", stdin);
        freopen("output.out", "w", stdout);
    }
    int n;cin>>n;
    For(i,n) {
        cin>>a[i];
    }
    For(i,40) {
        ll tmp = -1;
        For(j,n) if(a[j] & (1LL<<i)) {
            if(tmp==-1) {
                tmp=a[j];
            } else {
                tmp &= a[j];
            }
        }
        if(tmp!=-1) {
            // cout << "A " << tmp << endl;
            For(k,40) if(tmp & (1LL<<k)) {
                // cout << "B " << i << " " << k << endl;
                reps[i].insert(k);
            }
            todo[reps[i].size()].pb(i);
        }
    }
    // ll ans = 1;

    For(i,44)ans[i] = 1;
    for(int i=41;i>=0;i--) {
        trav(x,todo[i]) {
            pi tmp = {0,42};
            trav(y,reps[x]) if(reps[y].size() < reps[x].size()){
                tmp = max(tmp, {reps[y].size(),y});
            }
            int PAR = tmp.s;
            ans[PAR] *= (1+ans[x]);
            // cout << "C " << i << " " << tmp.f << " " << tmp.f << " " << tmp.s << endl;
            // cout << "D " << x << " " << ans[x] << endl;
        }

    }
    cout << ans[42] << endl;

    // For(i,40)if(!done[i]) {
    //     vector<set<int>> tmp;
    //     tmp.insert(reps[i]);
    //     vi vv;
    //     vv.pb(i);
    //     done[i] = true;
    //     trav(x,reps[i]) {
    //         tmp.insert(reps[x]);
    //     }
    //     For(j,40) if(i!=j) {
    //         bool ok = false;
    //         trav(x,reps[j])if(x==i) {
    //             ok = true;
    //         }
    //         if(ok) {
    //             tmp.insert(reps[j]);
    //             done[j] = true;
    //             vv.pb(j);
    //         }
    //     }
    //     trav(x,vv) {
    //         cout << i << " " << x << endl;
    //     }
    // }
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

4
0 1 3 5

output:

5

result:

ok 1 number(s): "5"

Test #2:

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

input:

5
0 1 2 3 4

output:

8

result:

ok 1 number(s): "8"

Test #3:

score: -100
Wrong Answer
time: 1ms
memory: 3652kb

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:

10740040962

result:

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