QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#497842#8729. Tikvaniarbuzick#0 0ms3848kbC++201.2kb2024-07-29 19:05:562024-07-29 19:06:00

Judging History

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

  • [2024-07-29 19:06:00]
  • 评测
  • 测评结果:0
  • 用时:0ms
  • 内存:3848kb
  • [2024-07-29 19:05:56]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;

constexpr int mod = 1e9 + 7;

constexpr int maxn = 405;

bitset<maxn> go[maxn];

void solve() {
    int n, m;
    cin >> n >> m;
    vector<vector<int>> g(n);
    for (int i = 0; i < m; ++i) {
        int u, v;
        cin >> u >> v;
        u--, v--;
        g[u].push_back(v);
    }
    for (int i = n - 1; i >= 0; --i) {
        for (auto j : g[i]) {
            go[i] |= go[j];
            go[i][j] = 1;
        }
    }
    int ans = 1;
    bitset<maxn> used;
    for (int i = 0; i < n; ++i) {
        if (used[i]) {
            continue;
        }
        bitset<maxn> add = go[i];
        for (int j = 0; j < n; ++j) {
            if (add[j] && used[j]) {
                add &= go[j].flip();
            }
        }
        for (int j = 0; j < n; ++j) {
            if (add[j]) {
                ans *= 2;
                if (ans >= mod) {
                    ans -= mod;
                }
            }
        }
        used[i] = 1;
        used |= add;
    }
    cout << ans << '\n';
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int t = 1;
    // cin >> t;
    while (t--) {
        solve();
    }
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 0
Wrong Answer

Test #1:

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

input:

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

output:

16

result:

wrong answer 1st numbers differ - expected: '32', found: '16'

Subtask #2:

score: 0
Skipped

Dependency #1:

0%

Subtask #3:

score: 0
Wrong Answer

Test #25:

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

input:

50 50
29 32
3 12
36 41
10 30
6 18
20 27
14 36
4 33
6 7
17 31
33 40
2 49
19 42
3 30
2 18
11 42
21 29
11 23
1 35
32 50
22 46
6 22
42 48
15 23
7 43
11 13
5 9
40 50
25 42
5 31
27 30
1 17
14 48
5 44
35 41
1 23
10 21
40 48
12 36
13 37
23 37
23 43
19 26
6 15
13 45
19 27
17 29
20 38
29 42
26 49

output:

23240159

result:

wrong answer 1st numbers differ - expected: '974740338', found: '23240159'

Subtask #4:

score: 0
Skipped

Dependency #1:

0%