結果
問題 | No.22 括弧の対応 |
ユーザー |
![]() |
提出日時 | 2015-05-27 16:44:42 |
言語 | C90 (gcc 12.3.0) |
結果 |
AC
|
実行時間 | 1 ms / 5,000 ms |
コード長 | 441 bytes |
コンパイル時間 | 378 ms |
コンパイル使用メモリ | 20,096 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-07-20 07:01:45 |
合計ジャッジ時間 | 1,101 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 19 |
コンパイルメッセージ
main.c: In function ‘main’: main.c:7:9: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 7 | scanf("%d%d", &N, &K); | ^~~~~~~~~~~~~~~~~~~~~ main.c:8:9: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 8 | scanf("%s", str); | ^~~~~~~~~~~~~~~~
ソースコード
#include <stdio.h> int main(void) { int i, N, K; int l, r, num; char str[10001]; scanf("%d%d", &N, &K); scanf("%s", str); if(str[K - 1] == '('){ i = K - 1; num = 1; while(num != 0){ i++; if(str[i] == '(')num++; else num--; } printf("%d\n", i + 1); } if(str[K - 1] == ')'){ i = K - 1; num = 1; while(num != 0){ i--; if(str[i] == ')')num++; else num--; } printf("%d\n", i + 1); } return 0; }