結果
| 問題 |
No.22 括弧の対応
|
| コンテスト | |
| ユーザー |
funakoshi
|
| 提出日時 | 2019-08-23 10:16:48 |
| 言語 | C (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 945 bytes |
| コンパイル時間 | 1,156 ms |
| コンパイル使用メモリ | 30,080 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-10-13 14:20:17 |
| 合計ジャッジ時間 | 2,186 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 14 WA * 5 |
ソースコード
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
#include <math.h>
int main(void)
{
char str[20000]="";
int len,specified,kakko=0,point=0;
scanf("%d %d",&len,&specified);
scanf("%s",str);
if(str[specified-1]=='(')
{
for(int i=specified-1;i<len;i++)
{
if(str[i]=='(')
{
kakko++;
}
else
{
kakko--;
}
if(kakko==0)
{
printf("%d",i+1);
break;
}
}
}
else
{
for(int i=len-1;0<=i;i--)
{
if(str[i]=='(')
{
kakko++;
}
else
{
kakko--;
}
if(kakko==0)
{
printf("%d",i+1);
}
}
}
}
funakoshi