QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#402445#7932. AND-OR closurechy_is_a_fishCompile Error//C++142.0kb2024-04-30 16:18:162024-04-30 16:18:18

Judging History

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

  • [2024-04-30 16:18:18]
  • 评测
  • [2024-04-30 16:18:16]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 2e5 + 5, M = (1 << 20), B = 40;
int n, m;
ll a[N], f[M], d[B], h[B], ans;
bool ok[B], g[B][B];
vector <int> ch, tp;
int main() 
{
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    cin >> n;
    for (int i = 1; i <= n; i++) cin >> a[i];
    for (int k = 0; k < B; k++)
    {
        ll val = (1ll << 40) - 1; int cnt = 0;
        for (int i = 1; i <= n; i++) 
            if (a[i] & (1 << k))
                val &= a[i], cnt++;
        if (cnt && cnt < n)
        {
            ok[k] = 1; 
            for (int j = 0; j < 40; j++)
                if (val & (1 << j)) g[k][j] = 1;
        }
    }
    for (int k = 0; k < B; k++)
    {
        if (!ok[k]) continue;
        bool fl = 1;
        for (int j : ch)
            if (g[k][j] && g[j][k]) 
                fl = 0;
        if (fl) ch.push_back(k);
    }
    m = ch.size();
    for (int i : ch) for (int j : ch) if (g[i][j] && i != j) d[j]++;
    for (int i : ch) if (!d[i]) tp.push_back(i);
    for (int i = 0; i < m; i++) for (int j : ch)
        if (g[tp[i]][j] && tp[i] != j) if (!--d[j]) tp.push_back(j);
	 assert(t.size() == m);
    for (int k = 0; k < m; k++) for (int j = 0; j < m; j++)
        if (g[tp[k]][tp[j]]) h[k] |= (1ll << j);
    int L = (m >> 1), R = m - L;
    for (int S = 0; S < (1 << R); S++)
    {
        ll val = 0;
        for (int j = 0; j < R; j++) if (S & (1 << j))
            val |= h[L+j] >> L;
        if (val == S) f[S]++;
    }
    for (int S = 1; S < (1 << R); S <<= 1)
        for (int _S = 0; _S < (1 << R); _S += (S << 1))
            for (int T = 0; T < S; T++) 
                f[_S+T] += f[S+_S+T];
    for (int S = 0; S < (1 << L); S++) 
    {
        ll val = 0;
        for (int j = 0; j < L; j++) if (S & (1 << j)) 
            val |= h[j];
        if (S == (val & (1 << L) - 1)) ans += f[val>>L];
    }
    cout << ans << "\n";
    return 0;
}

Details

In file included from /usr/include/c++/13/cassert:44,
                 from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:106,
                 from answer.code:1:
answer.code: In function ‘int main()’:
answer.code:41:17: error: ‘t’ was not declared in this scope; did you mean ‘tp’?
   41 |          assert(t.size() == m);
      |                 ^