結果
問題 | No.2742 Car Flow |
ユーザー | zatsu308 |
提出日時 | 2024-04-21 09:51:59 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,703 bytes |
コンパイル時間 | 2,518 ms |
コンパイル使用メモリ | 197,504 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-04-21 09:52:05 |
合計ジャッジ時間 | 4,752 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | WA | - |
testcase_01 | WA | - |
testcase_02 | WA | - |
testcase_03 | WA | - |
testcase_04 | WA | - |
testcase_05 | WA | - |
testcase_06 | WA | - |
testcase_07 | WA | - |
testcase_08 | WA | - |
testcase_09 | WA | - |
testcase_10 | WA | - |
testcase_11 | WA | - |
testcase_12 | WA | - |
testcase_13 | WA | - |
testcase_14 | WA | - |
testcase_15 | WA | - |
testcase_16 | WA | - |
testcase_17 | WA | - |
testcase_18 | WA | - |
testcase_19 | WA | - |
testcase_20 | WA | - |
testcase_21 | WA | - |
testcase_22 | WA | - |
testcase_23 | WA | - |
testcase_24 | WA | - |
testcase_25 | WA | - |
testcase_26 | WA | - |
testcase_27 | WA | - |
testcase_28 | WA | - |
testcase_29 | WA | - |
testcase_30 | WA | - |
testcase_31 | WA | - |
testcase_32 | WA | - |
testcase_33 | WA | - |
testcase_34 | WA | - |
testcase_35 | WA | - |
testcase_36 | WA | - |
testcase_37 | WA | - |
testcase_38 | WA | - |
testcase_39 | WA | - |
testcase_40 | AC | 2 ms
5,376 KB |
testcase_41 | AC | 1 ms
5,376 KB |
testcase_42 | WA | - |
testcase_43 | AC | 2 ms
5,376 KB |
testcase_44 | AC | 2 ms
5,376 KB |
testcase_45 | AC | 1 ms
5,376 KB |
testcase_46 | AC | 1 ms
5,376 KB |
testcase_47 | WA | - |
testcase_48 | WA | - |
testcase_49 | WA | - |
testcase_50 | WA | - |
ソースコード
#include <bits/stdc++.h> using namespace std; using ll = long long; constexpr ll mod = 998244353; template<ll mod> struct Mint { using M=Mint; ll v; M& put(ll x) { v=(x<mod)?x:x-mod; return *this; } Mint(ll x=0) { put(x%mod+mod); } M operator+(M m) {return M().put(v+m.v);} M operator-(M m) {return M().put(v+mod-m.v);} M operator*(M m) {return M().put(v*m.v%mod);} M operator/(M m) {return M().put(v*m.inv().v%mod);} // BEGIN IGNORE M operator+=(M m) { return put(v+m.v); } M operator-=(M m) { return put(v+mod-m.v); } M operator*=(M m) { return put(v*m.v%mod); } M operator/=(M m) { return put(v*m.inv().v%mod); } // END IGNORE bool operator==(M m) { return v==m.v; } M pow(ll m) const { M x=v, res=1; while (m) { if (m&1) res=res*x; x=x*x; m>>=1; } return res; } M inv() { return pow(mod-2); } }; using mint = Mint<mod>; struct UnionFind{ int n; vector<int> par; UnionFind(int n) : n(n), par(n, -1){} int find(int x){return par[x] < 0 ? x : find(par[x]);} bool Unite(int x, int y){ x = find(x), y = find(y); if(x == y)return false; // size[x] < size[y] if(par[x] > par[y])swap(x, y); par[x] += par[y]; par[y] = x; return true; } }; namespace std { template<typename T,typename U> struct hash<pair<T,U>> { size_t operator()(pair<T,U> const &val) const { return hash<T>{}(val.first)*1337^hash<U>{}(val.second); }}; } int main(){ int n; cin >> n; vector<int> a(n); for(int i = 0; i < n; ++i){ cin >> a[i]; } int cn = 0; for(int i = 0; i < n; ++i){ if(a[i] == 1 && a[(i + 1) % n] == 0){ ++cn; } } cout << (mint(cn) * mint(n).inv()).v << endl; }