Submission #3459154
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()) n,m = li() graph = [[] for _ in range(n)] path_list = [] path_set = set() for i in range(m): a,b = li_() graph[a].append(b) graph[b].append(a) if i == 0: st,ed = a,b path_list.append(a) path_list.append(b) path_set.add(a) path_set.add(b) ok = False if all([anex in path_set for anex in graph[a]]): ok = True elif all([bnex in path_set for bnex in graph[b]]): ok = True if ok: print(len(path_set)) path_list = [pi+1 for pi in path_list] print(*path_list) else: satisfied = False while not satisfied: for bnex in graph[ed]: satisfied = True if bnex in path_set: continue else: ed = bnex path_list.append(bnex) path_set.add(bnex) satisfied = False break path_list = [pi+1 for pi in path_list] print(len(path_set)) print(*path_list)
Submission Info
Submission Time | |
---|---|
Task | B - Hamiltonish Path |
User | polarbear08 |
Language | Python (3.4.3) |
Score | 0 |
Code Size | 1510 Byte |
Status | WA |
Exec Time | 288 ms |
Memory | 23088 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 | WA | 17 ms | 3064 KB |
sample_02.txt | AC | 17 ms | 3064 KB |
sample_03.txt | WA | 18 ms | 3064 KB |
subtask_1_01.txt | WA | 221 ms | 16836 KB |
subtask_1_02.txt | WA | 72 ms | 6388 KB |
subtask_1_03.txt | WA | 204 ms | 16712 KB |
subtask_1_04.txt | WA | 230 ms | 16176 KB |
subtask_1_05.txt | WA | 234 ms | 16200 KB |
subtask_1_06.txt | WA | 245 ms | 16304 KB |
subtask_1_07.txt | WA | 268 ms | 21320 KB |
subtask_1_08.txt | WA | 268 ms | 21192 KB |
subtask_1_09.txt | WA | 288 ms | 23088 KB |
subtask_1_10.txt | AC | 101 ms | 4596 KB |
subtask_1_11.txt | AC | 118 ms | 5236 KB |
subtask_1_12.txt | AC | 17 ms | 3064 KB |
subtask_1_13.txt | WA | 17 ms | 3064 KB |