結果

問題 No.2653 [Cherry 6th Tune] Re: start! (Make it Zero!)
ユーザー KudeKude
提出日時 2024-02-23 22:52:49
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,615 bytes
コンパイル時間 4,287 ms
コンパイル使用メモリ 273,724 KB
実行使用メモリ 6,676 KB
最終ジャッジ日時 2024-02-23 22:53:12
合計ジャッジ時間 8,392 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,676 KB
testcase_01 WA -
testcase_02 AC 23 ms
6,676 KB
testcase_03 AC 23 ms
6,676 KB
testcase_04 AC 21 ms
6,676 KB
testcase_05 AC 21 ms
6,676 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 20 ms
6,676 KB
testcase_09 AC 23 ms
6,676 KB
testcase_10 AC 23 ms
6,676 KB
testcase_11 AC 26 ms
6,676 KB
testcase_12 AC 25 ms
6,676 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 23 ms
6,676 KB
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 AC 25 ms
6,676 KB
testcase_34 AC 23 ms
6,676 KB
testcase_35 WA -
testcase_36 AC 22 ms
6,676 KB
testcase_37 WA -
testcase_38 WA -
testcase_39 AC 22 ms
6,676 KB
testcase_40 WA -
testcase_41 WA -
testcase_42 WA -
testcase_43 WA -
testcase_44 WA -
testcase_45 WA -
testcase_46 WA -
testcase_47 WA -
testcase_48 WA -
testcase_49 WA -
testcase_50 WA -
testcase_51 WA -
testcase_52 WA -
testcase_53 AC 39 ms
6,676 KB
testcase_54 AC 23 ms
6,676 KB
testcase_55 AC 28 ms
6,676 KB
testcase_56 AC 21 ms
6,676 KB
testcase_57 AC 24 ms
6,676 KB
testcase_58 AC 28 ms
6,676 KB
testcase_59 AC 28 ms
6,676 KB
testcase_60 AC 21 ms
6,676 KB
testcase_61 AC 22 ms
6,676 KB
testcase_62 AC 30 ms
6,676 KB
testcase_63 AC 27 ms
6,676 KB
testcase_64 AC 26 ms
6,676 KB
testcase_65 AC 24 ms
6,676 KB
testcase_66 AC 25 ms
6,676 KB
testcase_67 AC 25 ms
6,676 KB
testcase_68 AC 25 ms
6,676 KB
testcase_69 WA -
testcase_70 WA -
testcase_71 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
namespace {
#pragma GCC diagnostic ignored "-Wunused-function"
#include<atcoder/all>
#pragma GCC diagnostic warning "-Wunused-function"
using namespace std;
using namespace atcoder;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(i,n) for(int i = (int)(n) - 1; i >= 0; i--)
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
template<class T> bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } else return false; }
template<class T> bool chmin(T& a, const T& b) { if (b < a) { a = b; return true; } else return false; }
using ll = long long;
using P = pair<int,int>;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<ll>;
using VVL = vector<VL>;
using mint = modint998244353;

} int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int tt;
  cin >> tt;
  while (tt--) {
    int n, m;
    cin >> n >> m;
    VI x(n);
    rep(i, n) cin >> x[i];
    int i = find(all(x), -1) - x.begin();
    if (i == n) {
      int now = 0;
      int ans = 0;
      for (int x : x) {
        now = (now + x) % m;
        ans += now > 0;
      }
      if (now) ans = 0;
      cout << ans << '\n';
      continue;
    }
    int j = n - 1;
    while (x[j] != -1) j--;
    int cnt = count(all(x), -1);
    mint ans = j - i >= 2 ? mint(j - i) * (m - 1) * mint(m).pow(cnt - 2) : mint();
    mint coeff = mint(m).pow(cnt - 1);
    rep(_, 2) {
      int now = 0;
      for (int x : x) {
        if (x == -1) break;
        now = (now + x) % m;
        if (now) ans += coeff;
      }
      reverse(all(x));
    }
    cout << ans.val() << '\n';
  }
}
0