結果
問題 | No.22 括弧の対応 |
ユーザー |
![]() |
提出日時 | 2015-12-29 00:16:17 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 1 ms / 5,000 ms |
コード長 | 337 bytes |
コンパイル時間 | 177 ms |
コンパイル使用メモリ | 33,488 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-07-20 07:06:16 |
合計ジャッジ時間 | 801 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 19 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:7:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 7 | int a,b;scanf("%d%d%s",&a,&b,str); | ~~~~~^~~~~~~~~~~~~~~~~~~~
ソースコード
#include<stdio.h> #include<algorithm> using namespace std; char str[11000]; int dep[11000]; int main(){ int a,b;scanf("%d%d%s",&a,&b,str); int now=0;b--; for(int i=0;i<a;i++){ if(str[i]==')'){ now--; if(b==i){ printf("%d\n",dep[now]+1); } if(b==dep[now])printf("%d\n",i+1); }else{ dep[now]=i; now++; } } }