結果

問題 No.457 (^^*)
ユーザー butter_rollbutter_roll
提出日時 2016-12-14 17:05:32
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 5 ms / 2,000 ms
コード長 727 bytes
コンパイル時間 557 ms
コンパイル使用メモリ 69,880 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-20 06:48:58
合計ジャッジ時間 1,651 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 3 ms
4,380 KB
testcase_13 AC 5 ms
4,380 KB
testcase_14 AC 2 ms
4,380 KB
testcase_15 AC 3 ms
4,380 KB
testcase_16 AC 3 ms
4,376 KB
testcase_17 AC 2 ms
4,380 KB
testcase_18 AC 2 ms
4,376 KB
testcase_19 AC 1 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;

int main(void){

  int l1,l2,l3,l4,l5;
  int r1,r2,r3,r4,r5;
  int k[1111111];
  string s;
  int resl,resr;
  int i;
  resl=resr=0;
  cin>>s;
  k[s.length()]=0;
  for(i=s.length()-1;i>=0;i--){
    if(s[i]==')') k[i]=k[i+1]+1;
    else k[i]=k[i+1];
  }
  l1=l2=l3=l4=l5=0;
  r1=r2=r3=r4=r5=0;
  for(l1=s.find("(",0);l1!=-1;l1=s.find("(",l1+1)){
      l2=s.find("^",l1+1); r2=s.find("*",l1+1);
      l3=s.find("^",l2+1); r3=s.find("^",r2+1);
      l4=s.find("*",l3+1); r4=s.find("^",r3+1);
      if(l2!=-1&&l3!=-1&&l4!=-1) resl+=k[l4];
      if(r2!=-1&&r3!=-1&&r4!=-1) resr+=k[r4];
  }
  cout<<resl<<" "<<resr<<endl;
  return 0;
}
0