QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#582583#7925. ChayasqwerasdfWA 0ms7704kbC++201.5kb2024-09-22 16:53:202024-09-22 16:53:22

Judging History

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

  • [2024-09-22 16:53:22]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:7704kb
  • [2024-09-22 16:53:20]
  • 提交

answer

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

const long long MOD = 119<<23|1;

long long final_dp[1<<24];
long long possible_after[1<<24];
long long complement_after[1<<24];

long long ALL_MASK;

int n, m;
int a, b, c;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    cin >> n >> m;

    ALL_MASK = (1 << n) - 1;

    for (int i = 0; i <= ALL_MASK; ++i) {
        possible_after[i] = ALL_MASK;
        complement_after[i] = ALL_MASK;
    }

    for (int i = 0; i < m; ++i) {
        cin >> a >> b >> c;
        --a; --b; --c;

        long long set_mask = (1 << a) | (1 << c);
        long long possible_mask = ALL_MASK ^ (1 << b);

        possible_after[set_mask] &= possible_mask;
        complement_after[set_mask] &= possible_mask;
    }

    for (int i = 0; i < n; ++i) {
        for (int mask = 0; mask < (1 << n); ++mask) {
            if (mask & (1 << i)) {
                possible_after[mask] |= possible_after[mask ^ (1 << i)];
                complement_after[mask] |= complement_after[mask ^ (1 << i)];
            }
        }
    }

    final_dp[0] = 1;

    for (int mask = 0; mask < (1 << n); ++mask) {
        for (int i = 0; i < n; ++i) {
            if ((mask & (1 << i)) && (possible_after[mask ^ (1 << i)] & (1 << i)) && (complement_after[ALL_MASK ^ mask] & (1 << i))) {
                final_dp[mask] = final_dp[mask] + final_dp[mask ^ (1 << i)] % MOD;
            }
        }
    }

    cout << final_dp[ALL_MASK];

    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 7704kb

input:

5 4
1 2 4
2 3 5
3 2 4
1 3 2

output:

120

result:

wrong answer 1st lines differ - expected: '4', found: '120'