結果
| 問題 |
No.22 括弧の対応
|
| コンテスト | |
| ユーザー |
ノットカワズ
|
| 提出日時 | 2016-05-14 23:28:42 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
AC
|
| 実行時間 | 38 ms / 5,000 ms |
| コード長 | 556 bytes |
| コンパイル時間 | 214 ms |
| コンパイル使用メモリ | 12,544 KB |
| 実行使用メモリ | 10,880 KB |
| 最終ジャッジ日時 | 2024-07-20 07:13:30 |
| 合計ジャッジ時間 | 1,590 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 19 |
コンパイルメッセージ
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:17: SyntaxWarning: "is not" with 'int' literal. Did you mean "!="?
while check is not 0:
Main.py:21: SyntaxWarning: "is" with 'int' literal. Did you mean "=="?
if check is -1:
Main.py:22: 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()
ノットカワズ