結果
問題 | No.1647 Travel in Mitaru city 2 |
ユーザー | ansain |
提出日時 | 2021-08-13 23:14:13 |
言語 | Python3 (3.12.2 + numpy 1.26.4 + scipy 1.12.0) |
結果 |
RE
|
実行時間 | - |
コード長 | 2,127 bytes |
コンパイル時間 | 153 ms |
コンパイル使用メモリ | 12,672 KB |
実行使用メモリ | 111,304 KB |
最終ジャッジ日時 | 2024-10-03 22:55:43 |
合計ジャッジ時間 | 52,983 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 27 ms
10,752 KB |
testcase_01 | RE | - |
testcase_02 | AC | 26 ms
10,880 KB |
testcase_03 | WA | - |
testcase_04 | WA | - |
testcase_05 | AC | 26 ms
10,880 KB |
testcase_06 | AC | 26 ms
11,008 KB |
testcase_07 | WA | - |
testcase_08 | RE | - |
testcase_09 | RE | - |
testcase_10 | RE | - |
testcase_11 | RE | - |
testcase_12 | AC | 987 ms
83,996 KB |
testcase_13 | AC | 795 ms
87,872 KB |
testcase_14 | RE | - |
testcase_15 | AC | 1,005 ms
103,444 KB |
testcase_16 | AC | 974 ms
97,880 KB |
testcase_17 | AC | 817 ms
88,064 KB |
testcase_18 | AC | 828 ms
87,808 KB |
testcase_19 | RE | - |
testcase_20 | RE | - |
testcase_21 | RE | - |
testcase_22 | RE | - |
testcase_23 | AC | 1,034 ms
107,144 KB |
testcase_24 | AC | 891 ms
99,268 KB |
testcase_25 | RE | - |
testcase_26 | RE | - |
testcase_27 | RE | - |
testcase_28 | AC | 1,316 ms
111,304 KB |
testcase_29 | RE | - |
testcase_30 | AC | 1,048 ms
104,320 KB |
testcase_31 | RE | - |
testcase_32 | AC | 1,150 ms
109,576 KB |
testcase_33 | AC | 1,028 ms
100,536 KB |
testcase_34 | AC | 1,174 ms
111,296 KB |
testcase_35 | AC | 985 ms
101,752 KB |
testcase_36 | RE | - |
testcase_37 | AC | 1,215 ms
111,172 KB |
testcase_38 | AC | 914 ms
95,052 KB |
testcase_39 | AC | 867 ms
88,528 KB |
testcase_40 | AC | 925 ms
94,420 KB |
testcase_41 | RE | - |
testcase_42 | AC | 920 ms
94,888 KB |
testcase_43 | RE | - |
testcase_44 | AC | 87 ms
26,624 KB |
testcase_45 | RE | - |
testcase_46 | RE | - |
testcase_47 | RE | - |
testcase_48 | RE | - |
testcase_49 | RE | - |
testcase_50 | RE | - |
ソースコード
import sys from collections import defaultdict, Counter, deque from itertools import permutations, combinations, product, combinations_with_replacement, groupby, accumulate import operator from math import sqrt, gcd, factorial # from math import isqrt, prod, comb #python3.8用(notpypy) #from bisect import bisect_left, bisect_right #from functools import lru_cache, reduce #from heapq import heappush, heappop, heapify, heappushpop, heapreplace #import numpy as np #import networkx as nx #from networkx.utils import UnionFind #from numba import njit, b1, i1, i4, i8, f8 # numba例 @njit(i1(i4[:], i8[:, :]),cache=True) 引数i4配列、i8 2次元配列,戻り値i1 #from scipy.sparse import csr_matrix #from scipy.sparse.csgraph import shortest_path, floyd_warshall, dijkstra, bellman_ford, johnson, NegativeCycleError, maximum_bipartite_matching, maximum_flow, minimum_spanning_tree def input(): return sys.stdin.readline().rstrip() def divceil(n, k): return 1+(n-1)//k # n/kの切り上げを返す def yn(hantei, yes='Yes', no='No'): print(yes if hantei else no) def main(): sys.setrecursionlimit(10**5+1) mod = 10**9+7 mod2 = 998244353 h, w, n = map(int, input().split()) xy = [list(map(lambda x: int(x)-1, input().split())) for i in range(n)] graph = [[] for i in range(h+w)] for i, (x, y) in enumerate(xy): graph[x].append([y+h, i+1]) graph[y+h].append([x, i+1]) visited = [0]*(h+w) points = [] edges = [] def dfs(u, p): visited[u] = 1 for v, num in graph[u]: if v != p: if visited[v]==1: #print(points) #print(edges) ans=edges[points.index(v):]+[num] print(len(ans)) print(*ans) exit() points.append(v) edges.append(num) dfs(v, u) points.pop() edges.pop() for i in range(h): if visited[i]==0: points=[i] edges=[] dfs(i, -1) print(-1) if __name__ == '__main__': main()