結果
| 問題 | No.22 括弧の対応 |
| コンテスト | |
| ユーザー |
ノットカワズ
|
| 提出日時 | 2016-05-14 23:28:42 |
| 言語 | Python3 (3.15.2 + numpy 2.5.4 + scipy 1.18.1 + ACL) |
| 結果 |
AC
不安定
|
| 実行時間 | 28 ms / 5,000 ms |
| + 617µs | |
| コード長 | 556 bytes |
| 記録 | |
| コンパイル時間 | 53 ms |
| コンパイル使用メモリ | 14,720 KB |
| 実行使用メモリ | 11,776 KB |
| 最終ジャッジ日時 | 2026-11-10 18:58:23 |
| 合計ジャッジ時間 | 2,211 ms |
|
ジャッジサーバーID (参考情報) |
judge4_0 / judge3_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 20 |
コンパイルメッセージ
Main.py:6: SyntaxWarning: "is" with 'str' literal. Did you mean "=="?
if S[i] is '(':
Main.py:16: SyntaxWarning: "is" with 'int' literal. Did you mean "=="?
if check is 1:
Main.py:17: SyntaxWarning: "is not" with 'int' literal. Did you mean "!="?
while check is not 0:
Main.py:22: SyntaxWarning: "is not" with 'int' literal. Did you mean "!="?
while check is not 0:
ソースコード
#!/usr/bin/env python
# -*- coding: utf-8 -*-
def CheckAns(i, S):
if S[i] is '(':
return 1
else:
return -1
def kakko(K, S):
check = CheckAns(K - 1, S)
i = K - 1
if check is 1:
while check is not 0:
i += 1
check += CheckAns(i, S)
if check is -1:
while check is not 0:
i -= 1
check += CheckAns(i, S)
return i + 1
def main():
N, K = map(int, input().split())
S = input()
print(kakko(K, S))
if __name__ == '__main__':
main()
ノットカワズ