結果
| 問題 |
No.2733 Just K-times TSP
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-04-19 22:10:31 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 137 ms / 2,000 ms |
| コード長 | 2,411 bytes |
| コンパイル時間 | 3,123 ms |
| コンパイル使用メモリ | 256,724 KB |
| 実行使用メモリ | 32,152 KB |
| 最終ジャッジ日時 | 2024-10-11 15:28:46 |
| 合計ジャッジ時間 | 4,554 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 32 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
template <class F, class S>
ostream &operator<<(ostream &s, const pair<F, S> &v) {
s << "(" << v.first << ", " << v.second << ")";
return s;
}
template <ranges::range T,
class = enable_if_t<!is_convertible_v<T, string_view>>>
istream &operator>>(istream &s, T &&v) {
for (auto &&x : v) s >> x;
return s;
}
template <ranges::range T,
class = enable_if_t<!is_convertible_v<T, string_view>>>
ostream &operator<<(ostream &s, T &&v) {
for (auto &&x : v) s << x << ' ';
return s;
}
#ifdef LOCAL
template <class... T> void dbg(T... x) {
char e{};
((cerr << e << x, e = ' '), ...);
}
#define debug(x...) dbg(#x, '=', x, '\n')
#else
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
#define debug(...) ((void)0)
#endif
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define ff first
#define ss second
template <class T> inline constexpr T inf = numeric_limits<T>::max() / 2;
template <class T> bool chmin(T &a, T b) { return (b < a and (a = b, true)); }
template <class T> bool chmax(T &a, T b) { return (a < b and (a = b, true)); }
using u32 = unsigned int;
using i64 = long long;
using u64 = unsigned long long;
using i128 = __int128;
constexpr i64 mod = 998244353;
void solve() {
int n, m, k;
cin >> n >> m >> k;
vector<int> g(n);
for (int i = 0; i < m; i++) {
int u, v;
cin >> u >> v;
u--, v--;
g[u] |= (1 << v);
g[v] |= (1 << u);
}
vector<int> pw(n + 1, 1);
for (int i = 1; i <= n; i++) {
pw[i] = pw[i - 1] * (k + 1);
}
vector dp(n, vector<i64>(pw[n]));
for (int i = 0; i < n; i++) {
dp[i][pw[i]] = 1;
}
for (int s = 0; s < pw[n]; s++) {
for (int i = 0; i < n; i++)
if (dp[i][s]) {
for (int j = 0; j < n; j++)
if ((g[i] >> j & 1) and (s / pw[j] % (k + 1)) < k) {
(dp[j][s + pw[j]] += dp[i][s]) %= mod;
}
}
}
i64 ans = 0;
for (int i = 0; i < n; i++)
(ans += dp[i].back()) %= mod;
cout << ans << '\n';
}
signed main() {
cin.tie(0)->sync_with_stdio(false);
cin.exceptions(cin.failbit);
int t = 1;
// cin >> t;
while (t--) {
solve();
}
return 0;
}