結果

問題 No.2711 Connecting Lights
ユーザー kaityo_17kaityo_17
提出日時 2024-03-31 15:15:52
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 184 ms / 5,000 ms
コード長 3,153 bytes
コンパイル時間 4,051 ms
コンパイル使用メモリ 231,636 KB
実行使用メモリ 8,532 KB
最終ジャッジ日時 2024-03-31 15:16:09
合計ジャッジ時間 6,106 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,676 KB
testcase_01 AC 2 ms
6,676 KB
testcase_02 AC 1 ms
6,676 KB
testcase_03 AC 2 ms
6,676 KB
testcase_04 AC 2 ms
6,676 KB
testcase_05 AC 3 ms
6,676 KB
testcase_06 AC 2 ms
6,676 KB
testcase_07 AC 2 ms
6,676 KB
testcase_08 AC 3 ms
6,676 KB
testcase_09 AC 108 ms
6,676 KB
testcase_10 AC 75 ms
6,676 KB
testcase_11 AC 135 ms
7,700 KB
testcase_12 AC 30 ms
6,676 KB
testcase_13 AC 36 ms
6,676 KB
testcase_14 AC 4 ms
6,676 KB
testcase_15 AC 21 ms
6,676 KB
testcase_16 AC 4 ms
6,676 KB
testcase_17 AC 4 ms
6,676 KB
testcase_18 AC 5 ms
6,676 KB
testcase_19 AC 109 ms
6,912 KB
testcase_20 AC 38 ms
6,676 KB
testcase_21 AC 3 ms
6,676 KB
testcase_22 AC 2 ms
6,676 KB
testcase_23 AC 2 ms
6,676 KB
testcase_24 AC 66 ms
6,676 KB
testcase_25 AC 83 ms
6,676 KB
testcase_26 AC 183 ms
8,532 KB
testcase_27 AC 166 ms
8,532 KB
testcase_28 AC 184 ms
8,532 KB
testcase_29 AC 164 ms
8,532 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>
#define rep(i,a,n) for(ll i = a; i < n; i++)
#define yes (cout << "Yes" << endl)
#define YES (cout << "YES" << endl)
#define no (cout << "No" << endl)
#define NO (cout << "NO" << endl)
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define all(a)  (a).begin(),(a).end()
using namespace std;
using namespace atcoder;
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vd = vector<double>;
using vs = vector<string>;
using vl = vector<long long>;
using vvi = vector<vector<int>>;
using Graph = vector<vector<int>>;
const int mod = 998244353;
const int MOD = 1000000007;
const int dx[4] = {-1,0,1,0};
const int dy[4] = {0,1,0,-1};
ll chmin(ll a,ll b) {
    if(a < b) return a;
    else return b;
}
void O(vector<int> v) {
    rep(i,0,v.size()) {
        cout << v[i] << " ";
    }
    cout << endl;
}
void O(vector<string> v) {
    rep(i,0,v.size()) cout << v[i] << endl;
    cout << endl;
}
void O(int a) {
    cout << a << endl;
}
void O(ll a) {
    cout << a << endl;
}
void O(string s) {
    cout << s << endl;
}
struct unionfind {
  vector<int> data;
  unionfind(int size) : data(size, -1) { }
  bool unite(int x, int y) {
    x = root(x); y = root(y);
    if (x != y) {
      if (data[y] < data[x]) swap(x, y);
      data[x] += data[y]; data[y] = x;
    }
    return x != y;
  }
  bool same(int x, int y) {
    return root(x) == root(y);
  }
  int root(int x) {
    return data[x] < 0 ? x : data[x] = root(data[x]);
  }
  int size(int x) {
    return -data[root(x)];
  }
};
ll gcd(ll a, ll b) {
	a = abs(a); b = abs(b);
	if (a < b)swap(a, b);
	while (b) {
		ll r = a % b; a = b; b = r;
	}
	return a;
}
//x,yがax+by=gcd(a,b)の解になる x,yが格納
ll extgcd(ll a, ll b, ll& x, ll& y) {
	ll d = a;
	if (b != 0) {
		d = extgcd(b, a % b, y, x);
		y -= (a / b) * x;
	}
	else {
		x = 1; y = 0;
	}
	return d;
}
ll pow(ll a,ll b) {
    ll ans = 1;
    rep(i,0,b) ans *= a;
    return ans;
}
ll conb(ll a,ll b) {
    //aCb
    ll ans = 1;
    for(int i = a - b + 1;i <= a; i++ ) ans *= i;
    for(int i = 1; i <= b; i++) ans /= i;
    return ans;
}
int main() {
    ll n,m,k;
    cin >> n >> m >> k;
    ll dp[m + 1][1 << n];
    rep(i,0,m + 1) rep(j,0,1 << n) {
        dp[i][j] = 0;
    }
    rep(i,0,1 << n) {
        dp[0][i] = 1;
    }
    rep(i,1,m) {
        rep(j,0,1 << n) {
            bitset<10> bit(j);
            
            rep(kk,0,1 << n) {
                int p = 0;
                //jは一つ前
                bitset<10> bit2(kk);
                rep(l,0,n) {
                    if(bit[l] == 1 && bit2[l] == 1) {
                        p++;
                    }
                }
                if(p >= k) {
                    dp[i][kk] += dp[i - 1][j];
                    dp[i][kk] %= mod;
                }
            }
        }
    }
    /*rep(i,0,m) {
        rep(j,0,1 << n) {
            cout << i << " " << j << " " << dp[i][j]<< endl;
        }
    }*/
    ll ans = 0;
    rep(i,0,1 << n) {
        ans += dp[m - 1][i];
        ans %= mod;
    }
    cout << ans << endl;

}

    
0