Submission #1521644
Source Code Expand
#include<iostream> #include<vector> #include<map> using namespace std; vector<int>x[17]; int n, m, a[125], b[125], cnt, d[17]; map<long long, int>M; void dfs(int pos, int depth) { if (d[pos] != -1)return; d[pos] = depth; for (int i = 0; i < x[pos].size(); i++)dfs(x[pos][i], depth ^ 1); } int main() { cin >> n >> m; for (int i = 0; i < m; i++) { cin >> a[i] >> b[i]; a[i]--; b[i]--; } for (int i = 0; i < (1 << n); i++) { int bit[17]; for (int j = 0; j < n; j++)bit[j] = (i / (1 << j)) % 2; long long p = 0, q = 1, mod = (1LL << 30) - 1; for (int j = 0; j < n; j++)x[j].clear(); for (int j = 0; j < m; j++) { if (bit[a[j]] != bit[b[j]]) { p += q; x[a[j]].push_back(b[j]); x[b[j]].push_back(a[j]); } p %= mod; q *= 2; q %= mod; } for (int j = 0; j < m; j++)d[j] = -1; dfs(0, 0); bool OK = false; for (int j = 0; j < m; j++) { if (bit[a[j]] == bit[b[j]] && d[a[j]] != d[b[j]]) OK = true; } if (M[p] == 0 && OK == false) { cnt++; M[p] = 1; } } cout << cnt << endl; return 0; }
Submission Info
Submission Time | |
---|---|
Task | C - Orange Graph |
User | E869120 |
Language | C++14 (GCC 5.4.1) |
Score | 0 |
Code Size | 1052 Byte |
Status | RE |
Exec Time | 285 ms |
Memory | 2304 KB |
Judge Result
Set Name | Sample | All | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 0 / 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 | 7 ms | 768 KB |
sample_02.txt | AC | 1 ms | 256 KB |
sample_03.txt | AC | 1 ms | 256 KB |
test_01.txt | WA | 1 ms | 256 KB |
test_02.txt | AC | 1 ms | 256 KB |
test_03.txt | WA | 28 ms | 2304 KB |
test_04.txt | AC | 14 ms | 1280 KB |
test_05.txt | AC | 30 ms | 2304 KB |
test_06.txt | AC | 15 ms | 1280 KB |
test_07.txt | RE | 285 ms | 256 KB |
test_08.txt | RE | 94 ms | 256 KB |
test_09.txt | RE | 95 ms | 256 KB |
test_10.txt | RE | 95 ms | 256 KB |
test_11.txt | RE | 95 ms | 256 KB |
test_12.txt | RE | 94 ms | 256 KB |
test_13.txt | RE | 94 ms | 256 KB |
test_14.txt | RE | 94 ms | 256 KB |
test_15.txt | RE | 94 ms | 256 KB |
test_16.txt | RE | 95 ms | 256 KB |
test_17.txt | RE | 94 ms | 256 KB |
test_18.txt | RE | 94 ms | 256 KB |
test_19.txt | RE | 95 ms | 256 KB |
test_20.txt | RE | 94 ms | 256 KB |