結果

問題 No.457 (^^*)
ユーザー tsutajtsutaj
提出日時 2016-12-09 02:24:43
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 133 ms / 2,000 ms
コード長 2,106 bytes
コンパイル時間 807 ms
コンパイル使用メモリ 95,860 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-19 03:01:23
合計ジャッジ時間 2,401 ms
ジャッジサーバーID
(参考情報)
judge12 / judge10
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 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 1 ms
4,380 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 3 ms
4,376 KB
testcase_10 AC 14 ms
4,376 KB
testcase_11 AC 53 ms
4,376 KB
testcase_12 AC 107 ms
4,376 KB
testcase_13 AC 116 ms
4,380 KB
testcase_14 AC 2 ms
4,376 KB
testcase_15 AC 127 ms
4,380 KB
testcase_16 AC 133 ms
4,376 KB
testcase_17 AC 2 ms
4,380 KB
testcase_18 AC 1 ms
4,376 KB
testcase_19 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <climits>
#include <ctime>
#include <cassert>
using namespace std;

#define rep(i,a,n) for(int i=a; i<n; i++)
#define repq(i,a,n) for(int i=a; i<=n; i++)
#define repr(i,a,n) for(int i=a; i>=n; i--)
#define pb(a) push_back(a)
#define fr first
#define sc second
#define INF 2000000000
#define int long long int

#define X real()
#define Y imag()
#define EPS (1e-10)
#define EQ(a,b) (abs((a) - (b)) < EPS)
#define EQV(a,b) ( EQ((a).X, (b).X) && EQ((a).Y, (b).Y) )
#define LE(n, m) ((n) < (m) + EPS)
#define LEQ(n, m) ((n) <= (m) + EPS)
#define GE(n, m) ((n) + EPS > (m))
#define GEQ(n, m) ((n) + EPS >= (m))

typedef vector<int> VI;
typedef vector<VI> MAT;
typedef pair<int, int> pii;
typedef long long ll;

typedef complex<double> P;
typedef pair<P, P> L;
typedef pair<P, double> C;

int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
int const MOD = 1000000007;

namespace std {
    bool operator<(const P& a, const P& b) {
        return a.X != b.X ? a.X < b.X : a.Y < b.Y;
    }
}

signed main() {
    string s; cin >> s;
    int left = 0, right = 0;
    rep(i,0,s.length()) {
        int l_check[2] = {};
        int r_check[2] = {};
        if(s[i] == '(') {
            rep(j,i+1,s.length()) {
                if(l_check[0] <= 1 && l_check[1] == 0 && s[j] == '^') l_check[0]++;
                else if(l_check[0] == 2 && l_check[1] == 0 && s[j] == '*') l_check[1]++;
                else if(l_check[0] == 2 && l_check[1] == 1 && s[j] == ')') left++;

                if(r_check[0] == 0 && r_check[1] == 0 && s[j] == '*') r_check[1]++;
                else if(r_check[0] <= 1 && r_check[1] == 1 && s[j] == '^') r_check[0]++;
                else if(r_check[0] == 2 && r_check[1] == 1 && s[j] == ')') right++;
            }
        }
    }
    printf("%lld %lld\n", left, right);
    return 0;
}
0