Submission #1104865
Source Code Expand
#include <fstream> #include <iostream> #include <algorithm> #include <string.h> #include <string> #include <cassert> #include <deque> #include <set> #include <map> #include <vector> #include <regex> #define REP(i, n) for (int i = 0; i < n; i++) #define REPR(i, n) for (int i = n; i >= 0; i--) #define FOR(i, m, n) for (int i = m; i < n; i++) typedef long long ll; typedef unsigned long long ull; typedef unsigned int uint; using namespace std; //#define LOCAL_DEBUG vector<int> graph[9]; int main() { #ifdef LOCAL_DEBUG freopen("input1.txt","r", stdin); #endif int N, M; cin >> N >> M; REP(i, N) { int a, b; cin >> a >> b; graph[a].push_back(b); graph[b].push_back(a); } stack<set<int>> stk1; stack<int> stk2; stk1.push(set<int>()); stk2.push(1); int ans = 0; while (stk1.size() != 0) { set<int> s = stk1.top(); stk1.pop(); int i = stk2.top(); stk2.pop(); s.insert(i); if ((int)s.size() == N) { ans++; continue; } int size = graph[i].size(); REP(i1, size) { int j = graph[i][i1]; if (s.count(j) == 0) { set<int> new_s; for (set<int>::iterator it = s.begin(); it != s.end(); it++) { new_s.insert(*it); } stk1.push(new_s); stk2.push(j); } } } cout << ans << endl; return 0; }
Submission Info
Submission Time | |
---|---|
Task | C - One-stroke Path |
User | suikkee |
Language | C++14 (GCC 5.4.1) |
Score | 0 |
Code Size | 1328 Byte |
Status | WA |
Exec Time | 1 ms |
Memory | 256 KB |
Judge Result
Set Name | Sample | All | ||||||
---|---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 0 / 300 | ||||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | sample_01.txt, sample_02.txt |
All | sample_01.txt, sample_02.txt, subtask_1_01.txt, subtask_1_02.txt, subtask_1_03.txt, subtask_1_04.txt, subtask_1_05.txt, subtask_1_06.txt, subtask_1_07.txt, subtask_1_08.txt, subtask_1_09.txt, subtask_1_10.txt, subtask_1_11.txt, subtask_1_12.txt, subtask_1_13.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
sample_01.txt | AC | 1 ms | 256 KB |
sample_02.txt | AC | 1 ms | 256 KB |
subtask_1_01.txt | AC | 1 ms | 256 KB |
subtask_1_02.txt | AC | 1 ms | 256 KB |
subtask_1_03.txt | AC | 1 ms | 256 KB |
subtask_1_04.txt | WA | 1 ms | 256 KB |
subtask_1_05.txt | WA | 1 ms | 256 KB |
subtask_1_06.txt | AC | 1 ms | 256 KB |
subtask_1_07.txt | WA | 1 ms | 256 KB |
subtask_1_08.txt | WA | 1 ms | 256 KB |
subtask_1_09.txt | WA | 1 ms | 256 KB |
subtask_1_10.txt | WA | 1 ms | 256 KB |
subtask_1_11.txt | WA | 1 ms | 256 KB |
subtask_1_12.txt | WA | 1 ms | 256 KB |
subtask_1_13.txt | WA | 1 ms | 256 KB |