結果

問題 No.457 (^^*)
ユーザー te-sh
提出日時 2017-12-06 14:27:03
言語 D
(dmd 2.109.1)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 585 bytes
コンパイル時間 675 ms
コンパイル使用メモリ 94,768 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-06-12 22:49:59
合計ジャッジ時間 1,462 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 20
権限があれば一括ダウンロードができます

ソースコード

diff #

import std.algorithm, std.conv, std.range, std.stdio, std.string;

void main()
{
  auto s = readln.chomp;

  auto dpl = new int[](5), dpr = new int[](5);
  foreach (c; s)
    switch (c) {
    case '(':
      ++dpl[0];
      ++dpr[0];
      break;
    case '^':
      dpl[2] = dpl[1];
      dpl[1] = dpl[0];
      dpr[3] = dpr[2];
      dpr[2] = dpr[1];
      break;
    case '*':
      dpl[3] = dpl[2];
      dpr[1] = dpr[0];
      break;
    case ')':
      dpl[4] += dpl[3];
      dpr[4] += dpr[3];
      break;
    default:
      assert(0);
    }

  writeln(dpl[4], " ", dpr[4]);
}
0