結果
問題 | No.2539 スライムゲーム |
ユーザー |
|
提出日時 | 2023-10-04 00:02:46 |
言語 | PyPy3 (7.3.15) |
結果 |
RE
|
実行時間 | - |
コード長 | 871 bytes |
コンパイル時間 | 255 ms |
コンパイル使用メモリ | 82,304 KB |
実行使用メモリ | 121,728 KB |
最終ジャッジ日時 | 2024-09-26 00:55:05 |
合計ジャッジ時間 | 6,743 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 39 RE * 6 |
ソースコード
import reimport syssys.setrecursionlimit(10**5)content = input()pattern = r'^([\(\)]+)$'result = re.match(pattern, content)if not result:sys.exit("format error.")s = contentn = len(s)if n <= 0 or 10**5 < n:sys.exit("S")INF = 10**18 + 1def sep(l, r):acc = 0i = r - 1while i >= l:if s[i] == ')':acc += 1else:acc -= 1if acc == 0:return iif acc < 0:return -1i -= 1return -1def solve(l, r, dep):if dep >= 6:return INFif l >= r:return 0m = sep(l, r)if m == -1:return 1val = solve(l, m, dep) + 2**solve(m + 1, r - 1, dep + 1)if val >= INF:return INFreturn valres = solve(0, n, 0)if res >= INF:print("INFTY")else:print(res)