結果

問題 No.3070 Collecting Coins Speedrun 2
ユーザー Andrew8128
提出日時 2025-03-21 22:36:42
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 45 ms / 2,000 ms
コード長 821 bytes
コンパイル時間 1,156 ms
コンパイル使用メモリ 104,228 KB
実行使用メモリ 7,328 KB
最終ジャッジ日時 2025-03-21 22:37:10
合計ジャッジ時間 2,792 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 32
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;
#include <atcoder/math>
using namespace atcoder;
const int mod = 998244353;
int main()
{
  int N;
  cin >> N;
  vector<ll> c(N);
  int p = 0, n = 0, z = 0;
  for (int i = 0; i < N; i++)
  {
    cin >> c[i];
    if (c[i] == 0)
    {
      z++;
    }
    if (c[i] < 0)
    {
      n++;
    }
    if (0 < c[i])
    {
      p++;
    }
  }
  if (N == 1)
  {
    cout << 1 << '\n';
  }
  else if (n == 0)
  {
    cout << (z+1) * pow_mod(2, p-1, mod) % mod << '\n';
  }
  else if (p == 0)
  {
    cout << (z+1) * pow_mod(2, n-1, mod) % mod << '\n';
  }
  else
  {
    cout << 2 * (z*2+1) * pow_mod(2, p-1, mod) % mod * pow_mod(2, n-1, mod) % mod << '\n';
  }
  return 0;
}
/*
  File : ~/yukicoder/530/G.cpp
  Date : 2025/03/21
  Time : 22:27:53
*/
0