結果

問題 No.457 (^^*)
ユーザー ikdikd
提出日時 2016-12-11 18:22:50
言語 C++11
(gcc 13.3.0)
結果
AC  
実行時間 1,789 ms / 2,000 ms
コード長 746 bytes
コンパイル時間 523 ms
コンパイル使用メモリ 58,744 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-11-29 03:46:42
合計ジャッジ時間 8,169 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 20
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<vector>

using namespace std;

int main(){

   string S;
   cin>> S;

   int ans[]={0, 0};
   for(int i=0; i<S.size(); i++){
      if(S[i]=='('){
         int L=0, R=0;
         string l, r;
         for(int j=i+1; j<S.size(); j++){
            char c=S[j];
            if(l.empty()&&c=='*') l+='*';
            else if(l=="*"&&c=='^') l+='^';
            else if(l=="*^"&&c=='^') l+='^';
            if(r.empty()&&c=='^') r+='^';
            else if(r=="^"&&c=='^') r+='^';
            else if(r=="^^"&&c=='*') r+='*';
            if(c==')'&&l=="*^^") L++;
            if(c==')'&&r=="^^*") R++;
         }
         ans[0]+=L;
         ans[1]+=R;
      }
   }

   cout<< ans[1]<< " "<< ans[0]<< endl;

   return 0;
}

0