結果
| 問題 |
No.22 括弧の対応
|
| コンテスト | |
| ユーザー |
funakoshi
|
| 提出日時 | 2019-08-22 17:41:34 |
| 言語 | C (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 872 bytes |
| コンパイル時間 | 220 ms |
| コンパイル使用メモリ | 30,976 KB |
| 実行使用メモリ | 6,824 KB |
| 最終ジャッジ日時 | 2024-11-17 16:24:38 |
| 合計ジャッジ時間 | 1,022 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 1 WA * 18 |
ソースコード
#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;0<=i;i--)
{
if(str[i]=='(')
{
kakko++;
}
else
{
kakko--;
}
if(kakko==0)
{
printf("%d",i);
}
}
}
}
funakoshi