結果
問題 |
No.22 括弧の対応
|
ユーザー |
|
提出日時 | 2016-11-30 15:56:33 |
言語 | C90 (gcc 12.3.0) |
結果 |
RE
|
実行時間 | - |
コード長 | 342 bytes |
コンパイル時間 | 430 ms |
コンパイル使用メモリ | 20,224 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-11-27 13:59:23 |
合計ジャッジ時間 | 1,729 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 13 WA * 5 RE * 1 |
コンパイルメッセージ
main.c: In function ‘main’: main.c:6:9: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 6 | scanf("%d%d%s",&n,&k,s); | ^~~~~~~~~~~~~~~~~~~~~~~
ソースコード
#include <stdio.h> int main(void) { int n,k,c=1,i; char s[16384]; scanf("%d%d%s",&n,&k,s); i = k - 1; if(s[i] == '('){ while(1){ i++; if(s[i] == ')'){c--;}else{c++;} if(!c){printf("%d\n",i+1);break;} } } else{ while(1){ i++; if(s[i] == '('){c--;}else{c++;} if(!c){printf("%d\n",i+1);break;} } } return 0; }