結果

問題 No.3070 Collecting Coins Speedrun 2
ユーザー とんぼ
提出日時 2025-03-21 22:13:47
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 45 ms / 2,000 ms
コード長 709 bytes
コンパイル時間 3,512 ms
コンパイル使用メモリ 274,404 KB
実行使用メモリ 5,888 KB
最終ジャッジ日時 2025-03-21 22:13:53
合計ジャッジ時間 5,171 ms
ジャッジサーバーID
(参考情報)
judge2 / judge7
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 32
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
#include<atcoder/modint>
using namespace atcoder;
using mint=modint998244353;
using namespace std;
#define rep(i,N) for(i=0;i<N;i++)
#define ll long long

int main(void){
    ll N;
    ll C[100009];
    bool zero=0;

    ll i,j,k;

    cin>>N;
    rep(i,N){
        cin>>C[i];
        if(C[i]==0)zero=1;
    }

    if(N==1){
        cout<<1<<endl;
        return 0;
    }

    ll corner=0;
    if(C[0]<0)corner++;
    if(C[N-1]>0)corner++;
    if(zero)corner++;

    mint ans=mint(2).pow(N-corner);

    if(C[0]*C[N-1]<0)ans*=2;
    if(zero){
        ll turn=0;
        if(C[0]*C[N-1]<0)turn=3;
        else turn=2;
        ans*=turn;
    }

    cout<<ans.val()<<endl;

    return 0;
}
0