結果
| 問題 |
No.22 括弧の対応
|
| コンテスト | |
| ユーザー |
funakoshi
|
| 提出日時 | 2019-08-22 17:43:47 |
| 言語 | C (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 876 bytes |
| コンパイル時間 | 1,395 ms |
| コンパイル使用メモリ | 30,208 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-10-12 17:07:24 |
| 合計ジャッジ時間 | 1,410 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 2 WA * 17 |
ソースコード
#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;
scanf("%d %d",&len,&specified);
scanf("%s",str);
if(str[specified-1]=='(')
{
for(int i=0;i<len;i++)
{
if(str[i]=='(')
{
kakko++;
}
else
{
kakko--;
}
if(kakko==0)
{
printf("%d",i);
}
}
}
else
{
for(int i=len-1;0<=i;i--)
{
if(str[i]=='(')
{
kakko++;
}
else
{
kakko--;
}
if(kakko==0)
{
printf("%d",i+1);
}
}
}
}
funakoshi