結果

問題 No.265 数学のテスト
ユーザー alpha_virginisalpha_virginis
提出日時 2015-08-07 23:25:11
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,114 bytes
コンパイル時間 1,251 ms
コンパイル使用メモリ 144,308 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-25 06:24:23
合計ジャッジ時間 2,741 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 119 ms
4,376 KB
testcase_02 WA -
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 2 ms
4,376 KB
testcase_14 AC 1 ms
4,380 KB
testcase_15 AC 1 ms
4,380 KB
testcase_16 AC 2 ms
4,380 KB
testcase_17 AC 2 ms
4,380 KB
testcase_18 AC 1 ms
4,380 KB
testcase_19 AC 1 ms
4,380 KB
testcase_20 AC 2 ms
4,376 KB
testcase_21 AC 2 ms
4,380 KB
testcase_22 AC 1 ms
4,376 KB
testcase_23 AC 1 ms
4,380 KB
testcase_24 AC 2 ms
4,376 KB
testcase_25 AC 2 ms
4,376 KB
testcase_26 AC 1 ms
4,376 KB
testcase_27 AC 1 ms
4,380 KB
testcase_28 AC 2 ms
4,380 KB
testcase_29 AC 2 ms
4,376 KB
testcase_30 AC 2 ms
4,380 KB
testcase_31 AC 1 ms
4,376 KB
testcase_32 AC 1 ms
4,376 KB
testcase_33 AC 2 ms
4,376 KB
testcase_34 AC 2 ms
4,380 KB
testcase_35 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <stdint.h>
#include <sys/time.h>

char str[65536];
int n;
int a[16];

int main() {
  int d;
  int depth = 0;
  
  std::cin >> n >> d;
  scanf("%s", str);

  for(int i = 0; i <= n; ++i) {
    if( str[i] == '{' ) {
      depth += 1;
      continue;
    }
    if( str[i] == '}' ) {
      depth -= 1;
      continue;
    }
    if( str[i] == 'x' || ( '0' <= str[i] && str[i] <= '9' ) ) {
      int temp = 1;
      int red = 0;;
      for(int j = i; j <= n; ++j) {
        if( '0' <= str[j] && str[j] <= '9' ) {
          temp = str[j] - '0';
          red += 1;
          continue;
        }
        if( str[j] == '+' || str[j] == '}' || str[j] == '\0' ) {
          int d = (j-i+1)/2-red;
          for(int k = 0; k < depth; ++k) {
            temp *= d;
            d -= 1;
          }
          if( (j-i+1)/2-depth-red >= 0 ) {
            a[(j-i+1)/2-depth-red] += temp;
          }
          i = j-1;
          break;
        }
      }
      continue;
    }
  }

  for(int i = 0; i < d; ++i) {
    std::cout << a[i] << " ";
  }
  std::cout << a[d] << std::endl;
  
  return 0;
}

0