Submission #1442990
Source Code Expand
// clang-format off #include <bits/stdc++.h> #define int long long #define main signed main() #define loop(i, a, n) for (int i = (a); i < (n); i++) #define rep(i, n) loop(i, 0, n) #define all(v) (v).begin(), (v).end() #define rall(v) (v).rbegin(), (v).rend() #define prec(n) fixed << setprecision(n) #define pb push_back #define mp make_pair #define mt make_tuple #define fi first #define se second using namespace std; using pii = pair<int, int>; using vi = vector<int>; using vd = vector<double>; using vc = vector<char>; using vb = vector<bool>; using vs = vector<string>; using vpii = vector<pii>; using vvi = vector<vi>; using vvb = vector<vb>; using vvpii = vector<vpii>; template<typename A> using fn = function<A>; constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000; constexpr int MOD = 1000000007; constexpr double PI = acos(-1); template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; } template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; } constexpr bool odd(const int &n) { return n & 1; } constexpr bool even(const int &n) { return !odd(n); } // clang-format on main { int n, m; cin >> n >> m; vvi v(n, vi(n)); while (m--) { int x, y; cin >> x >> y; v[--x][--y] = true; } vi dp(1 << n); dp[0] = 1; rep(i, 1 << n) rep(j, n) { if (i >> j & 1) continue; bool valid = true; rep(k, n) valid &= !((i >> k & 1) && v[j][k]); if (valid) dp[i | 1 << j] += dp[i]; } cout << dp.back() << endl; }
Submission Info
Submission Time | |
---|---|
Task | D - 徒競走 |
User | AyaMorisawa |
Language | C++14 (GCC 5.4.1) |
Score | 100 |
Code Size | 1633 Byte |
Status | AC |
Exec Time | 26 ms |
Memory | 896 KB |
Judge Result
Set Name | Sample | Subtask1 | All | ||||||
---|---|---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 30 / 30 | 70 / 70 | ||||||
Status |
|
|
|
Set Name | Test Cases |
---|---|
Sample | 0_00.txt, 0_01.txt, 0_02.txt |
Subtask1 | 0_00.txt, 0_01.txt, 1_00.txt, 1_01.txt, 1_02.txt, 1_03.txt, 1_04.txt, 1_05.txt, 1_06.txt, 1_07.txt, 1_08.txt, 1_09.txt, 1_10.txt, 1_11.txt, 1_12.txt |
All | 0_00.txt, 0_01.txt, 0_02.txt, 1_00.txt, 1_01.txt, 1_02.txt, 1_03.txt, 1_04.txt, 1_05.txt, 1_06.txt, 1_07.txt, 1_08.txt, 1_09.txt, 1_10.txt, 1_11.txt, 1_12.txt, 2_00.txt, 2_01.txt, 2_02.txt, 2_03.txt, 2_04.txt, 2_05.txt, 2_06.txt, 2_07.txt, 2_08.txt, 2_09.txt, 2_10.txt, 2_11.txt, 2_12.txt, 2_13.txt, 2_14.txt, 2_15.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
0_00.txt | AC | 1 ms | 256 KB |
0_01.txt | AC | 1 ms | 256 KB |
0_02.txt | AC | 25 ms | 768 KB |
1_00.txt | AC | 1 ms | 256 KB |
1_01.txt | AC | 1 ms | 256 KB |
1_02.txt | AC | 1 ms | 256 KB |
1_03.txt | AC | 1 ms | 256 KB |
1_04.txt | AC | 1 ms | 256 KB |
1_05.txt | AC | 1 ms | 256 KB |
1_06.txt | AC | 1 ms | 256 KB |
1_07.txt | AC | 1 ms | 256 KB |
1_08.txt | AC | 1 ms | 256 KB |
1_09.txt | AC | 1 ms | 256 KB |
1_10.txt | AC | 1 ms | 256 KB |
1_11.txt | AC | 1 ms | 256 KB |
1_12.txt | AC | 1 ms | 256 KB |
2_00.txt | AC | 25 ms | 768 KB |
2_01.txt | AC | 25 ms | 768 KB |
2_02.txt | AC | 25 ms | 896 KB |
2_03.txt | AC | 25 ms | 768 KB |
2_04.txt | AC | 12 ms | 512 KB |
2_05.txt | AC | 12 ms | 512 KB |
2_06.txt | AC | 12 ms | 512 KB |
2_07.txt | AC | 12 ms | 512 KB |
2_08.txt | AC | 26 ms | 768 KB |
2_09.txt | AC | 26 ms | 768 KB |
2_10.txt | AC | 26 ms | 768 KB |
2_11.txt | AC | 25 ms | 768 KB |
2_12.txt | AC | 26 ms | 768 KB |
2_13.txt | AC | 26 ms | 768 KB |
2_14.txt | AC | 26 ms | 768 KB |
2_15.txt | AC | 25 ms | 768 KB |