結果

問題 No.2742 Car Flow
ユーザー GOTKAKOGOTKAKO
提出日時 2024-04-20 11:03:51
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 43 ms / 2,000 ms
コード長 2,178 bytes
コンパイル時間 2,082 ms
コンパイル使用メモリ 199,820 KB
実行使用メモリ 43,264 KB
最終ジャッジ日時 2024-04-20 11:03:56
合計ジャッジ時間 4,929 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
43,264 KB
testcase_01 AC 39 ms
43,136 KB
testcase_02 AC 40 ms
43,264 KB
testcase_03 AC 39 ms
43,136 KB
testcase_04 AC 38 ms
43,136 KB
testcase_05 AC 40 ms
43,264 KB
testcase_06 AC 43 ms
43,136 KB
testcase_07 AC 41 ms
43,264 KB
testcase_08 AC 39 ms
43,136 KB
testcase_09 AC 40 ms
43,136 KB
testcase_10 AC 28 ms
30,848 KB
testcase_11 AC 30 ms
33,408 KB
testcase_12 AC 24 ms
27,904 KB
testcase_13 AC 20 ms
21,760 KB
testcase_14 AC 19 ms
20,736 KB
testcase_15 AC 3 ms
6,940 KB
testcase_16 AC 39 ms
42,112 KB
testcase_17 AC 37 ms
41,600 KB
testcase_18 AC 4 ms
6,940 KB
testcase_19 AC 38 ms
41,344 KB
testcase_20 AC 12 ms
14,720 KB
testcase_21 AC 11 ms
12,416 KB
testcase_22 AC 32 ms
34,304 KB
testcase_23 AC 38 ms
39,680 KB
testcase_24 AC 20 ms
22,400 KB
testcase_25 AC 35 ms
38,144 KB
testcase_26 AC 40 ms
43,136 KB
testcase_27 AC 14 ms
15,744 KB
testcase_28 AC 16 ms
18,304 KB
testcase_29 AC 3 ms
6,940 KB
testcase_30 AC 33 ms
36,096 KB
testcase_31 AC 10 ms
12,160 KB
testcase_32 AC 34 ms
37,760 KB
testcase_33 AC 31 ms
34,688 KB
testcase_34 AC 17 ms
19,200 KB
testcase_35 AC 10 ms
12,288 KB
testcase_36 AC 2 ms
6,940 KB
testcase_37 AC 15 ms
14,720 KB
testcase_38 AC 32 ms
34,816 KB
testcase_39 AC 6 ms
8,576 KB
testcase_40 AC 1 ms
6,940 KB
testcase_41 AC 1 ms
6,944 KB
testcase_42 AC 2 ms
6,940 KB
testcase_43 AC 1 ms
6,940 KB
testcase_44 AC 2 ms
6,940 KB
testcase_45 AC 2 ms
6,940 KB
testcase_46 AC 1 ms
6,940 KB
testcase_47 AC 1 ms
6,940 KB
testcase_48 AC 2 ms
6,940 KB
testcase_49 AC 2 ms
6,944 KB
testcase_50 AC 1 ms
6,944 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

long long mod = 998244353;
//入力が必ずmod未満の時に使う.
struct mint{
    long long v = 0;
    mint(){} mint(int a){v = a;} mint(long long a){v = a;} mint(unsigned long long a){v = a;}
    long long val(){return v;}
    void modu(){v %= mod;}
 
    mint repeat2mint(long long a,long long b){
        mint ret = 1,p = a;
        while(b){if(b&1) ret *= p; p *= p; b >>= 1;}
        return ret;
    };
 
    mint operator-(){return mint(0)-mint(v);}
    mint operator+(mint b){return (v+b.v)%mod;}
    mint operator-(mint b){return (v-b.v+mod)%mod;}
    mint operator*(mint b){return v*b.v%mod;}
    mint operator/(mint b){
        if(b.v == 0) assert(false);
        return v*(repeat2mint(b.v,mod-2)).v%mod;
    }
 
    void operator+=(mint b){v = (v+b.v)%mod;}
    void operator-=(mint b){v = (v-b.v+mod)%mod;}
    void operator*=(mint b){v = v*b.v%mod;}
    void operator/=(mint b){
    if(b.v == 0) assert(false);
        v = v*repeat2mint(b.v,mod-2).v%mod;
    }
 
    void operator++(int){v = (v+1)%mod; return;}
    void operator--(int){v = (v-1+mod)%mod; return;}
    bool operator==(mint b){return v == b.v;}
    bool operator!=(mint b){return v != b.v;}
    bool operator>(mint b) {return v >  b.v;}
    bool operator>=(mint b){return v >= b.v;}
    bool operator<(mint b) {return v <  b.v;}
    bool operator<=(mint b){return v <= b.v;}
 
    mint pow(long long x){return repeat2mint(v,x);}
    mint inv(){return mint(1)/v;}
};			

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int N; cin >> N;
    vector B(50,vector<int>(N));
    int one = 0;
    for(auto &b : B.at(0)) cin >> b,one += b;

    one = min(N-one,one);
    cout << (mint(one)/N).v << endl;
return 0;

    for(int i=1; i<50; i++){
        for(int k=0; k<N; k++){
            int pos1 = (k-1+N)%N,pos2 = k,pos3 = (k+1)%N;
            if(B.at(i-1).at(pos1) == 1 && B.at(i-1).at(pos2) == 0) B.at(i).at(k) = 1;
            if(B.at(i-1).at(pos2) == 1 && B.at(i-1).at(pos3) == 1) B.at(i).at(k) = 1; 
        }
    }

    for(int i=0; i<50; i++){
        for(auto b : B.at(i)) cout << b << " "; cout << endl;
    }
}
0