Submission #1305755
Source Code Expand
//#define __USE_MINGW_ANSI_STDIO 0
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;
#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define IN(a, b, x) (a<=x&&x<b)
#define MP make_pair
#define PB push_back
#define MOD 1000000007
#define INF (1LL<<30)
#define LLINF (1LL<<60)
#define PI 3.14159265359
#define EPS 1e-12
//#define int ll
int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};
VI g[20];
bool a[20];
void dfs(int n, int d) {
for(int i: g[n]) {
if((((d & (1<<n)) == 0) != ((d & (1<<i)) == 0)) && !a[i]) {
a[i] = true;
dfs(i, d);
}
}
}
signed main(void)
{
int n, m;
cin >> n >> m;
REP(i, m) {
int x, y;
cin >> x >> y;
x--; y--;
g[x].PB(y);
g[y].PB(x);
}
int ans = 0;
REP(i, 1<<(n-1)) {
REP(j, n) a[j] = false;
dfs(0, i);
bool f = true;
REP(j, n) if(!a[j]) f = false;
if(f) ans++;
}
cout << ans << endl;
return 0;
}
Submission Info
Submission Time |
|
Task |
C - Orange Graph |
User |
ferin_tech |
Language |
C++14 (GCC 5.4.1) |
Score |
100 |
Code Size |
1144 Byte |
Status |
AC |
Exec Time |
43 ms |
Memory |
256 KB |
Judge Result
Set Name |
Sample |
All |
Score / Max Score |
0 / 0 |
100 / 100 |
Status |
|
|
Set Name |
Test Cases |
Sample |
sample_01.txt, sample_02.txt, sample_03.txt |
All |
sample_01.txt, sample_02.txt, sample_03.txt, test_01.txt, test_02.txt, test_03.txt, test_04.txt, test_05.txt, test_06.txt, test_07.txt, test_08.txt, test_09.txt, test_10.txt, test_11.txt, test_12.txt, test_13.txt, test_14.txt, test_15.txt, test_16.txt, test_17.txt, test_18.txt, test_19.txt, test_20.txt |
Case Name |
Status |
Exec Time |
Memory |
sample_01.txt |
AC |
1 ms |
256 KB |
sample_02.txt |
AC |
1 ms |
256 KB |
sample_03.txt |
AC |
1 ms |
256 KB |
test_01.txt |
AC |
1 ms |
256 KB |
test_02.txt |
AC |
1 ms |
256 KB |
test_03.txt |
AC |
2 ms |
256 KB |
test_04.txt |
AC |
2 ms |
256 KB |
test_05.txt |
AC |
3 ms |
256 KB |
test_06.txt |
AC |
2 ms |
256 KB |
test_07.txt |
AC |
12 ms |
256 KB |
test_08.txt |
AC |
6 ms |
256 KB |
test_09.txt |
AC |
35 ms |
256 KB |
test_10.txt |
AC |
16 ms |
256 KB |
test_11.txt |
AC |
25 ms |
256 KB |
test_12.txt |
AC |
14 ms |
256 KB |
test_13.txt |
AC |
30 ms |
256 KB |
test_14.txt |
AC |
14 ms |
256 KB |
test_15.txt |
AC |
35 ms |
256 KB |
test_16.txt |
AC |
15 ms |
256 KB |
test_17.txt |
AC |
38 ms |
256 KB |
test_18.txt |
AC |
18 ms |
256 KB |
test_19.txt |
AC |
43 ms |
256 KB |
test_20.txt |
AC |
19 ms |
256 KB |