結果

問題 No.2017 Mod7 Parade
ユーザー Nzt3Nzt3
提出日時 2022-07-22 22:10:47
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 913 bytes
コンパイル時間 2,191 ms
コンパイル使用メモリ 201,576 KB
実行使用メモリ 4,504 KB
最終ジャッジ日時 2023-09-17 10:23:23
合計ジャッジ時間 3,649 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 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 2 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
const int mod=1e9+7;
int mod7_10[6]={1, 3, 2, 6, 4, 5};

int d(int t,int l){
  return (mod7_10[l%6]-1)*4*t%7;
}

int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int N;
  cin>>N;
  vector<array<int,2>>A(N);
  for(int i=0;i<N;i++)cin>>A[i][0]>>A[i][1];
  array<array<int,6>,7>dp;
  for(int i=0;i<7;i++)for(int j=0;j<6;j++)dp[i][j]=0;
  dp[0][0]=1;
  for(int i=N-1;i>=0;i--){
    array<array<int,6>,7>dp2;
    for(int j=0;j<7;j++)for(int k=0;k<6;k++)dp2[j][k]=0;
    for(int j=0;j<7;j++){
      for(int k=0;k<6;k++){
        dp2[j][k]=(dp2[j][k]+dp[j][k])%mod;
        dp2[(j+d(A[i][0],A[i][1])*mod7_10[k])%7][(k+A[i][1])%6]=(dp2[(j+d(A[i][0],A[i][1])*mod7_10[k])%7][(k+A[i][1])%6]+dp[j][k])%mod;
      }
    }
    dp=dp2;
  }
  int ans=0;
  for(int i=0;i<7;i++){
    for(int j=0;j<6;j++){
      ans=(ans+(dp[i][j]*i))%mod;
    }
  }
  cout<<ans<<'\n';
}
0