結果

問題 No.457 (^^*)
ユーザー はむこはむこ
提出日時 2016-12-05 02:04:07
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 78 ms / 2,000 ms
コード長 848 bytes
コンパイル時間 1,383 ms
コンパイル使用メモリ 145,504 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-18 20:23:09
合計ジャッジ時間 2,561 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

#define rep(i,n) for(long long i = 0; i < (long long)(n); i++)
#define repi(i,a,b) for(long long i = (long long)(a); i < (long long)(b); i++)
using ll = long long; 

int main(void) {
    string s; cin >> s; 
    ll n = s.length();
    assert(n >= 1); assert(n <= 10000);
    rep(i, n) assert(s[i] == '(' || s[i] == '*' || s[i] == '^' || s[i] == ')');

    auto f = [&](string target) {
        ll ret = 0;
        rep(i, n) if (s[i] == '(') {
            ll state = 0;
            repi(j, i+1, n) {
                if (state < target.size() && target[state] == s[j]) 
                    state++;
                if (state == target.size() && s[j] == ')') 
                    ret++;
            }
        }
        return ret;
    };
    cout << f("^^*") << " " << f("*^^") << endl;

    return 0;
}
0