Submission #3459322
Source Code Expand
import sys stdin = sys.stdin sys.setrecursionlimit(10**5) def li(): return map(int, stdin.readline().split()) def li_(): return map(lambda x: int(x)-1, stdin.readline().split()) def lf(): return map(float, stdin.readline().split()) def ls(): return stdin.readline().split() def ns(): return stdin.readline().rstrip() def lc(): return list(ns()) def ni(): return int(stdin.readline()) def nf(): return float(stdin.readline()) from collections import deque n,m = li() graph = [[] for _ in range(n)] for _ in range(m): a,b = li_() graph[a].append(b) graph[b].append(a) path = deque([a,b]) path_set = set(path) ed = b satisfied = False while not satisfied: for nex in graph[ed]: if not nex in path_set: path_set.add(nex) path.append(nex) ed = nex continue satisfied = True satisfied = False while not satisfied: for nex in graph[ed]: if not nex in path_set: path_set.add(nex) path.appendleft(nex) ed = nex continue satisfied = True path = [pi+1 for pi in path] print(len(path)) print(*path)
Submission Info
Submission Time | |
---|---|
Task | B - Hamiltonish Path |
User | polarbear08 |
Language | Python (3.4.3) |
Score | 0 |
Code Size | 1227 Byte |
Status | WA |
Exec Time | 334 ms |
Memory | 21720 KB |
Judge Result
Set Name | Sample | All | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 0 / 500 | ||||||||
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, sample_01.txt, sample_02.txt, sample_03.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 | 21 ms | 3316 KB |
sample_02.txt | WA | 21 ms | 3316 KB |
sample_03.txt | WA | 21 ms | 3316 KB |
subtask_1_01.txt | WA | 291 ms | 17112 KB |
subtask_1_02.txt | WA | 82 ms | 6004 KB |
subtask_1_03.txt | WA | 253 ms | 16728 KB |
subtask_1_04.txt | WA | 288 ms | 16472 KB |
subtask_1_05.txt | WA | 299 ms | 16472 KB |
subtask_1_06.txt | WA | 286 ms | 16344 KB |
subtask_1_07.txt | WA | 334 ms | 21720 KB |
subtask_1_08.txt | WA | 317 ms | 21592 KB |
subtask_1_09.txt | WA | 315 ms | 21464 KB |
subtask_1_10.txt | WA | 124 ms | 4852 KB |
subtask_1_11.txt | AC | 155 ms | 5492 KB |
subtask_1_12.txt | AC | 20 ms | 3316 KB |
subtask_1_13.txt | AC | 20 ms | 3316 KB |