Submission #2249512
Source Code Expand
// ------------------------------------ // Date:2018/ 3/24 // Problem:One Stroke Path re_c.cpp // // ------------------------------------ #include <bits/stdc++.h> using namespace std; #define EACH(i,a) for (auto& i : a) #define FOR(i,a,b) for(int i=(int)a;i<(int)b;++i) #define RFOR(i,a,b) for(int i=(int)b-1;i>=(int)a;--i) #define REP(i,n) FOR(i,0,n) #define RREP(i,n) RFOR(i,0,n) #define ALL(a) (a).begin(),(a).end() #define debug(x) cerr << #x << ":" << x << endl; #define OK(ok) cout << (ok ? "Yes" : "No") << endl; typedef long long ll; void CINT(){} template <class Head,class... Tail> void CINT(Head&& head,Tail&&... tail) { cin >> head; CINT(move(tail)...); } #define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__) #define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__) #define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__) static const int MOD = 1e9 + 7; static const int MAX_N = 8; struct Edge { Edge(int _to) : to(_to){} int to; }; vector< Edge > e[MAX_N]; int N; bool check(vector< bool > state) { REP(v, state.size()) { if (!state[v]) return false; } return true; } int dfs(int from, vector< bool > _state) { int res = 0; _state[from] = true; if (check(_state)) { return 1; } EACH(to, e[from]) { if (_state[to.to]) continue; res += dfs(to.to, _state); } return res; } int main() { int M; cin >> N >> M; vector< int > a(M); vector< int > b(M); REP(i, M) { cin >> a[i] >> b[i]; a[i]--; b[i]--; e[a[i]].emplace_back(Edge(b[i])); e[b[i]].emplace_back(Edge(a[i])); } vector< bool > state(N, false); state[0] = true; int ans = dfs(0, state); cout << ans << endl; return 0; }
Submission Info
Submission Time | |
---|---|
Task | C - One-stroke Path |
User | task4233 |
Language | C++14 (GCC 5.4.1) |
Score | 300 |
Code Size | 1783 Byte |
Status | AC |
Exec Time | 3 ms |
Memory | 256 KB |
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 300 / 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 | AC | 3 ms | 256 KB |
subtask_1_05.txt | AC | 1 ms | 256 KB |
subtask_1_06.txt | AC | 1 ms | 256 KB |
subtask_1_07.txt | AC | 1 ms | 256 KB |
subtask_1_08.txt | AC | 1 ms | 256 KB |
subtask_1_09.txt | AC | 1 ms | 256 KB |
subtask_1_10.txt | AC | 1 ms | 256 KB |
subtask_1_11.txt | AC | 1 ms | 256 KB |
subtask_1_12.txt | AC | 2 ms | 256 KB |
subtask_1_13.txt | AC | 3 ms | 256 KB |