結果
問題 | No.2345 max(l,r) |
ユーザー | maksim |
提出日時 | 2023-06-09 21:45:43 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,691 bytes |
コンパイル時間 | 1,866 ms |
コンパイル使用メモリ | 179,952 KB |
実行使用メモリ | 18,172 KB |
最終ジャッジ日時 | 2023-08-30 13:07:13 |
合計ジャッジ時間 | 16,689 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge15 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 139 ms
9,744 KB |
testcase_01 | WA | - |
testcase_02 | AC | 157 ms
9,636 KB |
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 | AC | 158 ms
9,648 KB |
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 | AC | 232 ms
18,100 KB |
testcase_23 | AC | 235 ms
18,172 KB |
testcase_24 | AC | 156 ms
11,944 KB |
testcase_25 | AC | 161 ms
9,864 KB |
testcase_26 | AC | 160 ms
9,800 KB |
testcase_27 | AC | 159 ms
9,828 KB |
testcase_28 | AC | 144 ms
10,508 KB |
testcase_29 | AC | 151 ms
10,596 KB |
testcase_30 | AC | 142 ms
10,248 KB |
testcase_31 | AC | 157 ms
11,032 KB |
testcase_32 | AC | 145 ms
10,256 KB |
testcase_33 | AC | 149 ms
10,480 KB |
testcase_34 | AC | 137 ms
9,632 KB |
testcase_35 | AC | 139 ms
9,996 KB |
testcase_36 | AC | 142 ms
10,096 KB |
testcase_37 | AC | 145 ms
10,244 KB |
testcase_38 | AC | 162 ms
11,256 KB |
testcase_39 | WA | - |
testcase_40 | AC | 173 ms
11,396 KB |
testcase_41 | AC | 163 ms
11,216 KB |
testcase_42 | AC | 170 ms
11,312 KB |
testcase_43 | AC | 168 ms
11,276 KB |
testcase_44 | WA | - |
testcase_45 | WA | - |
testcase_46 | WA | - |
testcase_47 | AC | 173 ms
11,516 KB |
testcase_48 | WA | - |
testcase_49 | WA | - |
testcase_50 | WA | - |
testcase_51 | WA | - |
testcase_52 | WA | - |
testcase_53 | WA | - |
testcase_54 | WA | - |
testcase_55 | WA | - |
testcase_56 | WA | - |
testcase_57 | WA | - |
testcase_58 | WA | - |
testcase_59 | WA | - |
testcase_60 | WA | - |
testcase_61 | WA | - |
testcase_62 | WA | - |
testcase_63 | WA | - |
testcase_64 | WA | - |
testcase_65 | WA | - |
testcase_66 | WA | - |
testcase_67 | WA | - |
testcase_68 | AC | 208 ms
9,712 KB |
コンパイルメッセージ
main.cpp: 関数 ‘int32_t main()’ 内: main.cpp:24:43: 警告: structured bindings only available with ‘-std=c++17’ or ‘-std=gnu++17’ [-Wc++17-extensions] 24 | vector<pair<int,int> > v;for(auto [key,val]:u) v.push_back({key,val}); | ^ main.cpp:28:18: 警告: structured bindings only available with ‘-std=c++17’ or ‘-std=gnu++17’ [-Wc++17-extensions] 28 | for(auto [ma,c]:v) | ^
ソースコード
#include <bits/stdc++.h> using namespace std; #define int long long const int p=998244353; int po(int a,int b) {if(b==0) return 1; if(b==1) return a; if(b%2==0) {int u=po(a,b/2);return (u*u)%p;} else {int u=po(a,b-1);return (a*u)%p;}} int inv(int x) {return po(x,p-2);} const int maxn=4e5+5; int fact[maxn];int invf[maxn]; int c1(int n,int k) { if(n<k || n<0 || k<0) return 0; int res=fact[n];res*=invf[k];res%=p;res*=invf[n-k];res%=p;return res; } int32_t main() { ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0); fact[0]=1;for(int i=1;i<maxn;++i) {fact[i]=(fact[i-1]*i)%p;} for(int i=0;i<maxn;++i) invf[i]=inv(fact[i]); int t;cin>>t; while(t--) { int n,m;cin>>n>>m;int a[n];for(int i=0;i<n;++i) cin>>a[i]; map<int,int> u;for(int i=0;i<n;++i) u[a[i]]++; vector<pair<int,int> > v;for(auto [key,val]:u) v.push_back({key,val}); sort(v.begin(),v.end());reverse(v.begin(),v.end()); int l=n,r=n; int res=1;int tot=0;int rem=v.size(); for(auto [ma,c]:v) { --rem; if(ma==r-c) { ++tot; if(l==r && rem) {res*=2;res%=p;} r-=c; } else if(ma==l-c) { ++tot; l-=c; } else { int h=(l+r-c); if(h%2==1) {res*=0;res%=p;} if(h!=2*ma) {res*=0;res%=p;} tot+=2; int o=l-h/2; res*=c1(c,o); l=h/2;r=h/2; } } res*=c1(m,tot);res%=p; cout<<(res%p+p)%p<<'\n'; } return 0; }