QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#497952 | #8728. Tablica | arbuzick# | 0 | 0ms | 0kb | C++20 | 2.0kb | 2024-07-29 20:53:19 | 2024-07-29 20:53:23 |
answer
#include <bits/stdc++.h>
using namespace std;
constexpr int mod = 1000000007;
constexpr int maxn = 405;
bitset<maxn> go[maxn];
void solve() {
int n, m;
cin >> n >> m;
vector<vector<int>> g(n), _g(n);
for (int i = 0; i < m; ++i) {
int u, v;
cin >> u >> v;
u--, v--;
g[u].push_back(v);
_g[v].push_back(u);
}
for (int i = n - 1; i >= 0; --i) {
go[i] = 0;
for (auto j : g[i]) {
go[i] |= go[j];
go[i][j] = 1;
}
}
int ans = 1;
bitset<maxn> used = 0;
for (int i = 0; i < n; ++i) {
if (used[i]) {
continue;
}
vector<int> used2(n);
for (int j = 0; j < n; ++j) {
if (go[i][j]) {
if (!used[j]) {
ans = ans * 2LL % mod;
} else if (!used2[j]) {
ans = ans * 2LL % mod;
used2[j] = 1;
queue<int> q;
q.push(j);
while (!q.empty()) {
int v = q.front();
q.pop();
for (auto u : g[v]) {
if (!used2[u]) {
used2[u] = 1;
q.push(u);
}
}
for (auto u : _g[v]) {
if (used[u] && !used2[u]) {
used2[u] = 1;
q.push(u);
}
}
}
}
}
}
used[i] = 1;
used |= go[i];
}
cout << ans << '\n';
}
signed main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int t = 1;
// cin >> t;
while (t--) {
solve();
}
return 0;
}
詳細信息
Subtask #1:
score: 0
Runtime Error
Test #1:
score: 0
Runtime Error
input:
5 6
output:
result:
Subtask #2:
score: 0
Skipped
Dependency #1:
0%
Subtask #3:
score: 0
Skipped
Dependency #1:
0%
Subtask #4:
score: 0
Skipped
Dependency #1:
0%