結果
問題 |
No.22 括弧の対応
|
ユーザー |
|
提出日時 | 2016-10-30 06:38:25 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 5,000 ms |
コード長 | 205 bytes |
コンパイル時間 | 1,749 ms |
コンパイル使用メモリ | 167,468 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-07-20 07:17:52 |
合計ジャッジ時間 | 2,428 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 19 |
コンパイルメッセージ
main.cpp:2:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type] 2 | main(){int n,k,a=0;std::string s;std::cin>>n>>k>>s;k--;if(s[k]=='(')do{if(s[k]=='(')a++;else a--;}while(a&&k++);else do{if(s[k]=='(')a++;else a--;}while(a&&k--);printf("%d\n",++k);} | ^~~~
ソースコード
#include<bits/stdc++.h> main(){int n,k,a=0;std::string s;std::cin>>n>>k>>s;k--;if(s[k]=='(')do{if(s[k]=='(')a++;else a--;}while(a&&k++);else do{if(s[k]=='(')a++;else a--;}while(a&&k--);printf("%d\n",++k);}