結果

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

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using ll = long long;
using mint = atcoder::modint998244353;

template<class T> istream& operator >> (istream& is, vector<T>& vec) {
    for(T& x : vec) is >> x;
    return is;
}

template<class T> ostream& operator << (ostream& os, const vector<T>& vec) {
    if(vec.empty()) return os;
    os << vec[0];
    for(auto it = vec.begin(); ++it != vec.end(); ) os << ' ' << *it;
    return os;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<ll> a(n);
    cin >> a;
    if(a[0] * a[n - 1] < 0){
        int p = lower_bound(a.begin(), a.end(), 0) - a.begin();
        // -2 -1 0 1 2
        if(a[p] == 0){
            cout << (6 * mint(2).pow(p - 1) * mint(2).pow(n - p - 2)).val() << '\n';
        }else{
        // -2 -1 1 2
            cout << (2 * mint(2).pow(p - 1) * mint(2).pow(n - p - 1)).val() << '\n';
        }
    }else{
        cout << mint(2).pow(n - 1).val() << '\n';
    }
}
0