結果
問題 | No.2742 Car Flow |
ユーザー |
|
提出日時 | 2024-04-20 11:03:51 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 64 ms / 2,000 ms |
コード長 | 2,178 bytes |
コンパイル時間 | 2,029 ms |
コンパイル使用メモリ | 198,688 KB |
最終ジャッジ日時 | 2025-02-21 06:13:38 |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 50 |
ソースコード
#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;}}