結果

問題 No.457 (^^*)
ユーザー ei1333333ei1333333
提出日時 2016-12-08 21:09:33
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 780 bytes
コンパイル時間 1,387 ms
コンパイル使用メモリ 145,140 KB
実行使用メモリ 8,768 KB
最終ジャッジ日時 2023-08-19 02:31:07
合計ジャッジ時間 5,469 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

#define reps(i, j, n) for(int i = int(j); i < int(n); i++)
#define rep(i, n) reps(i, 0, n)

int main()
{
  string S;
  cin >> S;

  int L = 0, R = 0;
  rep(i, S.size()) {
    if(S[i] == '(') {
      reps(j, i + 1, S.size()) {
        if(S[j] == ')') {
          int l1 = 0, l2 = 0;
          for(int k = i + 1; k < j; k++) {
            l1 |= S[k] == '*';
            if(l1) l2 += S[k] == '^';
            if(l2 >= 2) break;
          }
          int r1 = 0, r2 = 0;
          for(int k = j - 1; k > i; k--) {
            r1 |= S[k] == '*';
            if(r1) r2 += S[k] == '^';
            if(r2 >= 2) break;
          }
          L += l2 >= 2;
          R += r2 >= 2;
        }
      }
    }
  }
  cout << R << " " << L << endl;
}
0