結果

問題 No.2711 Connecting Lights
ユーザー Iroha_3856Iroha_3856
提出日時 2024-03-31 14:31:19
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 299 ms / 5,000 ms
コード長 4,434 bytes
コンパイル時間 4,730 ms
コンパイル使用メモリ 287,524 KB
実行使用メモリ 6,676 KB
最終ジャッジ日時 2024-03-31 14:31:27
合計ジャッジ時間 7,529 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,676 KB
testcase_01 AC 2 ms
6,676 KB
testcase_02 AC 2 ms
6,676 KB
testcase_03 AC 2 ms
6,676 KB
testcase_04 AC 2 ms
6,676 KB
testcase_05 AC 4 ms
6,676 KB
testcase_06 AC 2 ms
6,676 KB
testcase_07 AC 2 ms
6,676 KB
testcase_08 AC 4 ms
6,676 KB
testcase_09 AC 177 ms
6,676 KB
testcase_10 AC 78 ms
6,676 KB
testcase_11 AC 139 ms
6,676 KB
testcase_12 AC 33 ms
6,676 KB
testcase_13 AC 38 ms
6,676 KB
testcase_14 AC 5 ms
6,676 KB
testcase_15 AC 23 ms
6,676 KB
testcase_16 AC 4 ms
6,676 KB
testcase_17 AC 5 ms
6,676 KB
testcase_18 AC 7 ms
6,676 KB
testcase_19 AC 110 ms
6,676 KB
testcase_20 AC 41 ms
6,676 KB
testcase_21 AC 4 ms
6,676 KB
testcase_22 AC 3 ms
6,676 KB
testcase_23 AC 4 ms
6,676 KB
testcase_24 AC 119 ms
6,676 KB
testcase_25 AC 138 ms
6,676 KB
testcase_26 AC 297 ms
6,676 KB
testcase_27 AC 179 ms
6,676 KB
testcase_28 AC 299 ms
6,676 KB
testcase_29 AC 166 ms
6,676 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

//AtCoder-Library
#if __has_include(<atcoder/all>)
#include<atcoder/all>
using namespace atcoder;
using mint = atcoder::modint998244353;
#endif

//PBDS-tree
#if __has_include(<ext/pb_ds/assoc_container.hpp>)
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#include<ext/pb_ds/tag_and_trait.hpp>
using namespace __gnu_pbds;
template<class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
//tree.find_by_order(k) = tree[k] (0-indexed)
//tree.order_of_key(k) = tree.lower_bound(k) - tree.begin()
//Note: Can only be used for non-multiple sets.
#endif

#define vec vector
#define ll long long
#define ull unsigned long long
#define vi vec<int>
#define vll vec<ll>
#define vb vec<bool>
#define vvi vec<vi>
#define vvll vec<vll>
#define vvb vec<vb>
#define vvvi vec<vvi>
#define vvvll vec<vvll>
#define vvvb vec<vvb>
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pli pair<ll, int>
#define pq priority_queue
template<class T> using spq = priority_queue<T, vector<T>, greater<T>>;
#define eb emplace_back
#define pb push_back
#define spa " "

#define all(x) (x).begin(), (x).end()
#define rep(i, l, r) for (int i=(int)(l); i<(int)(r); i++)
#define REP(i, l, r) for (int i=(int)(l); i<=(int)(r); i++)
#define siz(x) (int)x.size()

template<class T>bool chmax(T &a, T b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, T b) { if (b<a) { a=b; return 1; } return 0; }

//Slice(A, l, r) = A[l, r)
template<class T>
vector<T> Slice(vector<T> A, int l, int r) {
    assert(0 <= l && l < (int)A.size());
    assert(0 <= r && r <= (int)A.size());
    vector<T> ret;
    for (int i = l; i<r; i++) ret.push_back(A[i]);
    return ret;
}

//Slice(S, l, r) = S[l, r)
string Slice(string s, int l, int r) {
    assert(0 <= l && l < (int)s.size());
    assert(0 <= r && r <= (int)s.size());
    string ret;
    for (int i = l; i<r; i++) ret += s[i];
    return ret;
}

ll Ceil(ll x, ll y) {
    assert(y != 0);
    if ((x >= 0) == (y >= 0)) {
        return (abs(x) + abs(y)-1)/abs(y);
    }
    else {
        return -(abs(x)/abs(y));
    }
}

ll Floor(ll x, ll y) {
    assert(y != 0);
    if ((x >= 0) == (y >= 0)) {
        return abs(x)/abs(y);
    }
    else {
        return -((abs(x) + abs(y)-1)/abs(y));
    }
}

template<class T, class U> 
istream &operator>>(istream &is, pair<T, U> &p) {
    is >> p.first >> p.second;
    return is;
}

template<class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
    os << p.first << " " << p.second;
    return os;
}

template <class T>
istream &operator>>(istream &is, vector<T> &v) {
    for(auto &x : v) {
        is >> x;
    }
    return is;
}

template <class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
    for(int i = 0; i < (int)v.size(); i++) {
        if(i != (int)v.size() - 1)
            os << v[i] << " ";
        else
            os << v[i];
    }
    return os;
}

template<class T>
void print(T A, bool f = true) {
    cerr << A;
    if (f) cerr << endl;
}

template<class T, class U>
void print(pair<T, U> A, bool f = true) {
    cerr << "{" << A.first << ", " << A.second << "}";
    if (f) cerr << endl;
}

template<class T> 
void print(vector<T> A, bool f = true) {
    cerr << "{";
    for (int i = 0; i<(int)A.size(); i++) {
        print(A[i], false);
        if (i+1 != (int)A.size()) cerr << ", ";
    }
    cerr << "}";
    if (f) cerr << endl;
}

#define debug(x) cerr << #x << " = "; print(x)
#define debug2(x) cerr << #x << " = "; print(x, false)

struct IoSetup {
    IoSetup() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(15);
        cerr << fixed << setprecision(15);
    }
} iosetup;

struct Edge {
    int to;
    int cost;
    Edge(int to, int cost) : to(to), cost(cost) {}
};

const int mod1 = 998244353;
const int mod2 = 1000000007;
const int inf = 1000010000;
const ll INF = 1LL<<60;

int main() {
    int N, M, K; cin >> N >> M >> K;
    vector<vector<mint>> dp(M, vector<mint>(1<<N));
    rep(i, 0, 1<<N) dp[0][i] = 1;
    rep(i, 0, M-1) rep(j, 0, 1<<N) rep(k, 0, 1<<N) {
        int cnt = 0;
        rep(l, 0, N) if ((j>>l&1) && (k>>l&1)) cnt++;
        if (cnt >= K) dp[i+1][k] += dp[i][j];
    }
    mint ans = 0;
    rep(i, 0, 1<<N) ans += dp[M-1][i];
    cout << ans.val() << endl;
}
0