結果
問題 |
No.2742 Car Flow
|
ユーザー |
|
提出日時 | 2024-04-12 22:49:26 |
言語 | C++17(gcc12) (gcc 12.3.0 + boost 1.87.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 726 bytes |
コンパイル時間 | 7,163 ms |
コンパイル使用メモリ | 255,480 KB |
最終ジャッジ日時 | 2025-02-21 00:39:53 |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 16 WA * 32 TLE * 2 |
ソースコード
#include<bits/stdc++.h> using namespace std; using ll=long long; constexpr int MOD=998244353; namespace Lib{ ll modpow(ll a,ll n){ long long ret=1,t=a; while(n>0){ if(n&1)ret=ret*t%MOD; t=t*t%MOD; n/=2; } return ret; } } int main(){ ios::sync_with_stdio(false); cin.tie(nullptr); time_t start=clock(); int N; cin>>N; vector B(N,0); for(int &i:B)cin>>i; while(clock()-start<1900000){ vector B2(N,0); for(int j=0;j<N;j++){ B2[j]=(B[(j+N-1)%N]&(1-B[j]))|((B[j]&B[(j+1)%N])); } for(int j=0;j<N;j++){ B[j]=B2[j]; } } ll ans=0; for(int i=0;i<N;i++){ ans+=(1-B[i])&B[(i+1)%N]; } ans=ans*Lib::modpow(N,MOD-2)%MOD; cout<<ans<<'\n'; }