Submission #1243800
Source Code Expand
#include <bits/stdc++.h>
using namespace std;
#define INF 1001000100010001000
#define MOD 1000000007
#define EPS 1e-10
#define int long long
#define rep(i, N) for (int i = 0; i < N; i++)
#define Rep(i, N) for (int i = 1; i < N; i++)
#define For(i, a, b) for (int i = (a); i < (b); i++)
#define pb push_back
#define eb emplece_back
#define mp make_pair
#define i_i pair<int, int>
#define vi vector<int>
#define vvi vector<vi >
#define vb vector<bool>
#define vvb vector<vb >
#define vp vector< i_i >
#define all(a) (a).begin(), (a).end()
#define Int(x) int x; scanf("%lld", &x);
#define int2(x, y) int x, y; scanf("%lld %lld", &x, &y);
//int dxy[5] = {0, 1, 0, -1, 0};
// assign
signed main()
{
int2(n, m);
bool g[n][n];
memset(g, false, sizeof(g));
rep(i, m) {
int2(a, b);
g[a-1][b-1] = true;
}
int dp[1 << n + 1]; memset(dp, 0, sizeof(dp));
rep(i, n) dp[1 << i] = 1;
int s = (1 << n) -1;
Rep(i, s) {
rep(j, n) { // 終端に追加するうさぎ
if (i & (1 << j)) continue;
bool fl = true;
rep(k, n) {
if (i & (1 << k)) { // 必ずiにjが含まれない事が言える
if (g[j][k]) { // 終端に追加したいので
// iのどの要素にも勝ってはいけない
fl = false; break;
}
}
}
if (fl) dp[i | (1 << j) ] += dp[i];
}
}
cout << dp[s] << endl;
return 0;
}
Submission Info
Submission Time |
|
Task |
D - 徒競走 |
User |
Ti11192916 |
Language |
C++14 (GCC 5.4.1) |
Score |
100 |
Code Size |
1635 Byte |
Status |
AC |
Exec Time |
27 ms |
Memory |
1280 KB |
Compile Error
./Main.cpp: In function ‘int main()’:
./Main.cpp:23:56: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
#define int2(x, y) int x, y; scanf("%lld %lld", &x, &y);
^
./Main.cpp:30:5: note: in expansion of macro ‘int2’
int2(n, m);
^
./Main.cpp:23:56: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
#define int2(x, y) int x, y; scanf("%lld %lld", &x, &y);
^
./Main.cpp:34:9: note: in expansion of macro ‘int2’
int2(a, b);
^
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 |
27 ms |
1280 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 |
27 ms |
1280 KB |
2_01.txt |
AC |
23 ms |
1280 KB |
2_02.txt |
AC |
23 ms |
1280 KB |
2_03.txt |
AC |
23 ms |
1280 KB |
2_04.txt |
AC |
10 ms |
768 KB |
2_05.txt |
AC |
7 ms |
768 KB |
2_06.txt |
AC |
10 ms |
768 KB |
2_07.txt |
AC |
7 ms |
768 KB |
2_08.txt |
AC |
22 ms |
1280 KB |
2_09.txt |
AC |
18 ms |
1280 KB |
2_10.txt |
AC |
18 ms |
1280 KB |
2_11.txt |
AC |
11 ms |
1280 KB |
2_12.txt |
AC |
26 ms |
1280 KB |
2_13.txt |
AC |
24 ms |
1280 KB |
2_14.txt |
AC |
25 ms |
1280 KB |
2_15.txt |
AC |
25 ms |
1280 KB |