結果
| 問題 |
No.457 (^^*)
|
| コンテスト | |
| ユーザー |
chaemon
|
| 提出日時 | 2016-12-08 00:15:02 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 2,000 ms |
| コード長 | 2,281 bytes |
| コンパイル時間 | 846 ms |
| コンパイル使用メモリ | 90,308 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-11-28 04:24:06 |
| 合計ジャッジ時間 | 1,510 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 20 |
ソースコード
// #includes {{{
#include <algorithm>
#include <numeric>
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <list>
#include <deque>
#include <stack>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <cstring>
#include <cmath>
using namespace std;
// }}}
// pre-written code {{{
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define RREP(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();++i)
#define LET(x,a) __typeof(a) x(a)
//#define IFOR(i,it,c) for(__typeof((c).begin())it=(c).begin();it!=(c).end();++it,++i)
#define ALL(c) (c).begin(), (c).end()
#define MP make_pair
#define EXIST(e,s) ((s).find(e)!=(s).end())
#define RESET(a) memset((a),0,sizeof(a))
#define SET(a) memset((a),-1,sizeof(a))
#define PB push_back
#define DEC(it,command) __typeof(command) it=command
//debug
#define dump(x) cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define debug2(x) cerr << #x << " = [";REP(__ind,(x).size()){cerr << (x)[__ind] << ", ";}cerr << "] (L" << __LINE__ << ")" << endl;
const int INF=0x3f3f3f3f;
typedef long long Int;
typedef unsigned long long uInt;
#ifdef __MINGW32__
typedef double rn;
#else
typedef long double rn;
#endif
typedef pair<int,int> pii;
/*
#ifdef MYDEBUG
#include"debug.h"
#include"print.h"
#endif
*/
// }}}
string S;
string l = "(^^*)", r = "(*^^)";
int next_hat[10101];
int next_star[10101];
int close_count[10101];
int main(){
int ans0 = 0, ans1 = 0;
cin>>S;
int N = S.size();
int h_i = N, s_i = N, c_c = 0;
for(int i=N-1;i>=0;i--){
next_hat[i] = h_i;
next_star[i] = s_i;
close_count[i] = c_c;
if(S[i]=='^')h_i = i;
else if(S[i]=='*')s_i = i;
else if(S[i]==')')c_c++;
}
REP(i,N){
if(S[i]!='(')continue;
int j = i;
j = next_hat[j];
if(j==N)continue;
j = next_hat[j];
if(j==N)continue;
j = next_star[j];
if(j==N)continue;
ans0+=close_count[j];
}
REP(i,N){
if(S[i]!='(')continue;
int j = i;
j = next_star[j];
if(j==N)continue;
j = next_hat[j];
if(j==N)continue;
j = next_hat[j];
if(j==N)continue;
ans1+=close_count[j];
}
printf("%d %d\n",ans0,ans1);
return 0;
}
chaemon