結果
問題 | No.457 (^^*) |
ユーザー |
![]() |
提出日時 | 2016-12-14 17:05:32 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 5 ms / 2,000 ms |
コード長 | 727 bytes |
コンパイル時間 | 726 ms |
コンパイル使用メモリ | 70,144 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-11-30 07:28:39 |
合計ジャッジ時間 | 1,413 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 20 |
ソースコード
#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; }