結果
問題 |
No.3032 ホモトピー入門
|
ユーザー |
![]() |
提出日時 | 2025-02-21 23:20:07 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,234 bytes |
コンパイル時間 | 519 ms |
コンパイル使用メモリ | 82,352 KB |
実行使用メモリ | 116,412 KB |
最終ジャッジ日時 | 2025-02-21 23:20:17 |
合計ジャッジ時間 | 9,336 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 6 WA * 31 |
ソースコード
n, m = map(int, input().split()) S = [input() for _ in range(n)] t = "ULDR" dy = [1, 0, -1, 0] dx = [0, -1, 0 , 1] ans = 0 for i in range(n): s = S[i] x, y = 0, 0 rot0 = 0 rot1 = 0 for j in range(m): ind = t.index(s[j]) nx, ny = x+dx[ind], y+dy[ind] if (x, nx) == (0, 1): if 1 <= y: rot0 += 1 else: rot0 -= 1 if (x, nx) == (1, 0): if 1 <= y: rot0 -= 1 else: rot0 += 1 if (x, nx) == (-1, 0): if 1 <= y: rot1 += 1 else: rot1 -= 1 if (x, nx) == (0, -1): if 1 <= y: rot0 -= 1 else: rot0 += 1 if (y, ny) == (0, 1): if x <= -1: rot0 += 1 rot1 += 1 elif x <= 0: rot0 += 1 rot1 -= 1 else: rot0 -= 1 rot1 -= 1 if (y, ny) == (1, 0): if x <= -1: rot0 -= 1 rot1 -= 1 elif x <= 0: rot0 -= 1 rot1 += 1 else: rot0 += 1 rot1 += 1 x, y = nx, ny if rot0 == rot1 == 0: ans += 1 print(ans)