結果
問題 | No.22 括弧の対応 |
ユーザー | Yang33 |
提出日時 | 2015-12-28 12:01:31 |
言語 | C90 (gcc 11.4.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 525 bytes |
コンパイル時間 | 344 ms |
コンパイル使用メモリ | 20,692 KB |
実行使用メモリ | 5,720 KB |
最終ジャッジ日時 | 2023-10-19 11:28:42 |
合計ジャッジ時間 | 13,251 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge15 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | TLE | - |
testcase_01 | -- | - |
testcase_02 | -- | - |
testcase_03 | -- | - |
testcase_04 | -- | - |
testcase_05 | -- | - |
testcase_06 | -- | - |
testcase_07 | -- | - |
testcase_08 | -- | - |
testcase_09 | -- | - |
testcase_10 | -- | - |
testcase_11 | -- | - |
testcase_12 | -- | - |
testcase_13 | -- | - |
testcase_14 | -- | - |
testcase_15 | -- | - |
testcase_16 | -- | - |
testcase_17 | -- | - |
testcase_18 | -- | - |
コンパイルメッセージ
main.c: In function ‘main’: main.c:8:9: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 8 | scanf("%d %d", &n, &k); | ^~~~~~~~~~~~~~~~~~~~~~ main.c:9:9: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 9 | scanf("%s", kakko); | ^~~~~~~~~~~~~~~~~~
ソースコード
#include<stdio.h> int main(void) { int n, k, i,check=1; char kakko[10000]; scanf("%d %d", &n, &k); scanf("%s", kakko); if (kakko[k-1]=='(') { for (i = k;check!=0; i++) { if (kakko[i] == '(')check = check + 1; else check = check - 1; if (check == 0) { printf("%d",i+1); break; } } } else//")" { for (i = k;check!=0; i--) { if (kakko[i] == '(')check = check - 1; else check = check + 1; if (check == 0) { printf("%d", i+1); break; } } } return 0; }