QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#355769#7932. AND-OR closurengpin04#WA 1ms5876kbC++141.9kb2024-03-17 07:07:522024-03-17 07:07:53

Judging History

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

  • [2024-03-17 07:07:53]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:5876kb
  • [2024-03-17 07:07:52]
  • 提交

answer

#include <bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair
#define ALL(x) x.begin(), x.end()
#define bit(x) (1LL << (x))
#define getbit(x, i) (((x) >> (i)) & 1)
using namespace std;

template <typename T1, typename T2> bool mini(T1 &a, T2 b) {
    if (a > b) {a = b; return true;} return false;
};

template <typename T1, typename T2> bool maxi(T1 &a, T2 b) {
    if (a < b) {a = b; return true;} return false;
};

int n;
int sz;
long A[200003];
long B[200003];
vector<long> mem[40];
vector<int> vec[45];

long dp[45];
void dfs(int u)
{
    long res = 1;
    for(int v : vec[u])
    {
        dfs(v);
        res = res*dp[v];
    }
    
    dp[u] = res+1;
    // cout << u << " " << dp[u] << "\n";
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin >> n;
    for(int i = 1; i <= n; i++)
    {
        cin >> A[i];
        for(int j = 0; j < 40; j++)
        {
            long bit = (1LL<<j);
            if(bit&A[i])
                mem[j].push_back(A[i]);
        }
    }
    set<long> st;
    for(int j = 0; j < 40; j++)
    {
        long sand = (1LL<<40)-1;
        if(mem[j].size() == 0) continue;
        for(long x : mem[j])
        {
            sand &= x;
            // cout << j << " " << x << "\n";
        }
            
        st.insert(sand);
    }
    
    for(long x : st)
    {
        B[++sz] = x;
    }
    for(int i = 1; i <= sz; i++)
    {
        long mx = 0;
        int idx = 0;
        for(int j = 1; j < i; j++)
        {
            // cout << i << " " << j << " " << (B[i]&B[j]) << '\n';
            if((B[i]&B[j]) == B[j])
            {
                mx = max(mx, B[j]);
                idx = j;
            }
        }
        // cout << "EDJ : " << i << " " << idx << "\n";
        vec[idx].push_back(i);
    }
    dfs(0);
    cout << dp[0]-1 << "\n";
    return 0;
}



Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 3848kb

input:

4
0 1 3 5

output:

5

result:

ok 1 number(s): "5"

Test #2:

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

input:

5
0 1 2 3 4

output:

8

result:

ok 1 number(s): "8"

Test #3:

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

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:

209

result:

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