結果

問題 No.2017 Mod7 Parade
ユーザー simansiman
提出日時 2023-09-15 23:23:06
言語 C++17(clang)
(17.0.6 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,093 bytes
コンパイル時間 6,621 ms
コンパイル使用メモリ 107,248 KB
実行使用メモリ 4,504 KB
最終ジャッジ日時 2023-09-15 23:23:24
合計ジャッジ時間 4,470 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <cassert>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <climits>
#include <map>
#include <queue>
#include <set>
#include <cstring>
#include <vector>

using namespace std;
typedef long long ll;

const ll MOD = 1000000007;

int main() {
  int K;
  cin >> K;
  vector<int> D(K);
  vector<int> L(K);

  for (int i = 0; i < K; i++) {
    cin >> D[i] >> L[i];
  }

  vector<int> mod7 = {1, 3, 2, 6, 4, 5};
  ll dp[6][7];
  memset(dp, 0, sizeof(dp));
  dp[0][0] = 1;

  for (int i = K - 1; i >= 0; --i) {
    ll temp[6][7];
    memcpy(temp, dp, sizeof(dp));

    int d = D[i];
    int l = L[i];
    for (int j = 0; j < 6; ++j) {
      ll sum = 0;
      for (int k = 0; k < l % 6; ++k) {
        sum += mod7[(j + k) % 6] * d;
      }
      for (int k = 0; k < 7; ++k) {
        temp[(j + l) % 6][(k + sum) % 7] += dp[j][k];
      }
    }

    memcpy(dp, temp, sizeof(dp));
  }

  ll ans = 0;
  for (int i = 0; i < 6; ++i) {
    for (int j = 0; j < 7; ++j) {
      ans += dp[i][j] * j;
      ans %= MOD;
    }
  }

  cout << ans << endl;

  return 0;
}
0