結果
| 問題 |
No.22 括弧の対応
|
| コンテスト | |
| ユーザー |
suppy193
|
| 提出日時 | 2015-05-27 16:33:43 |
| 言語 | C90 (gcc 12.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 429 bytes |
| コンパイル時間 | 101 ms |
| コンパイル使用メモリ | 20,480 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-07-06 11:03:30 |
| 合計ジャッジ時間 | 822 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 15 WA * 4 |
コンパイルメッセージ
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;
num = 1;
while(num != 0){
if(str[i] == '(')num++;
else num--;
i++;
}
printf("%d\n", i);
}
if(str[K - 1] == ')'){
i = K - 2;
num = 1;
while(num != 0){
if(str[i] == '(')num++;
else num--;
i--;
}
printf("%d\n", i);
}
return 0;
}
suppy193