結果
問題 |
No.2274 三角彩色
|
ユーザー |
![]() |
提出日時 | 2023-04-14 22:07:30 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
RE
|
実行時間 | - |
コード長 | 1,237 bytes |
コンパイル時間 | 3,530 ms |
コンパイル使用メモリ | 277,660 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2024-10-10 12:54:04 |
合計ジャッジ時間 | 4,897 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 17 RE * 5 |
ソースコード
#include <bits/stdc++.h> #include <atcoder/dsu> #include <atcoder/modint> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int64_t N; int M, B, Q; cin >> N >> M >> B >> Q; using atcoder::modint; modint::set_mod(B); vector<array<int64_t, 2>> edges(M); for (auto& [i, j] : edges) { cin >> i >> j; } vector<int64_t> U; for (auto [i, j] : edges) { U.push_back(i); U.push_back(j); } ranges::sort(U); U.resize(size(ranges::unique(U))); atcoder::dsu d(size(U)); modint all = 1; for (auto [i, j] : edges) { auto ti = ranges::lower_bound(U, i) - begin(U); auto tj = ranges::lower_bound(U, j) - begin(U); if (d.same(ti, tj)) { all *= 2; } else { d.merge(ti, tj); } } vector<bitset<400>> v; while (Q--) { bitset<400> cur; for (int _ = 3; _--;) { int i; cin >> i; if (i < 400) { cur[i] = 1; } } for (const auto& e : v) { auto pos = e._Find_first(); if (pos < 400 && cur[pos]) { cur ^= e; } } if (cur.any()) { v.push_back(cur); } } auto ans = modint(2).pow(size(v)); cout << (all - ans).val() << ' ' << ans.val() << '\n'; }