結果
問題 | No.22 括弧の対応 |
ユーザー |
|
提出日時 | 2017-03-15 13:27:08 |
言語 | C90 (gcc 12.3.0) |
結果 |
AC
|
実行時間 | 1 ms / 5,000 ms |
コード長 | 378 bytes |
コンパイル時間 | 127 ms |
コンパイル使用メモリ | 20,864 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-07-20 07:20:26 |
合計ジャッジ時間 | 1,104 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 19 |
コンパイルメッセージ
main.c: In function ‘main’: main.c:8:23: warning: format ‘%s’ expects argument of type ‘char *’, but argument 4 has type ‘char (*)[10000]’ [-Wformat=] 8 | scanf("%d %d %s",&n,&k,&s); | ~^ ~~ | | | | char * char (*)[10000] main.c:8:9: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 8 | scanf("%d %d %s",&n,&k,&s); | ^~~~~~~~~~~~~~~~~~~~~~~~~~
ソースコード
#include <stdio.h> int main(void) { int n,k,i,count=0; char s[10000],c; scanf("%d %d %s",&n,&k,&s); if(s[k-1]=='('){ for(i=k-1;i<n;i++){ if(s[i]=='(') count++; else count--; if(count==0) break; } printf("%d",i+1); } else { for(i=k-1;i>=0;i--){ if(s[i]==')') count++; else count--; if(count==0) break; } printf("%d",i+1); } return 0; }