結果
問題 | No.1354 Sambo's Treasure |
ユーザー | blackyuki |
提出日時 | 2021-01-17 11:26:08 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
WA
(最新)
AC
(最初)
|
実行時間 | - |
コード長 | 3,905 bytes |
コンパイル時間 | 2,397 ms |
コンパイル使用メモリ | 217,720 KB |
実行使用メモリ | 21,368 KB |
最終ジャッジ日時 | 2024-11-29 13:19:12 |
合計ジャッジ時間 | 6,406 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
6,820 KB |
testcase_01 | AC | 2 ms
6,820 KB |
testcase_02 | AC | 2 ms
6,820 KB |
testcase_03 | AC | 2 ms
6,820 KB |
testcase_04 | WA | - |
testcase_05 | WA | - |
testcase_06 | WA | - |
testcase_07 | AC | 1 ms
6,816 KB |
testcase_08 | AC | 2 ms
6,820 KB |
testcase_09 | AC | 2 ms
6,820 KB |
testcase_10 | WA | - |
testcase_11 | AC | 1 ms
6,820 KB |
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 | AC | 2 ms
6,816 KB |
testcase_22 | AC | 2 ms
6,820 KB |
testcase_23 | AC | 84 ms
21,244 KB |
testcase_24 | AC | 76 ms
21,180 KB |
testcase_25 | AC | 131 ms
21,268 KB |
testcase_26 | AC | 123 ms
21,196 KB |
testcase_27 | AC | 85 ms
21,368 KB |
testcase_28 | AC | 75 ms
21,132 KB |
testcase_29 | WA | - |
testcase_30 | AC | 93 ms
21,148 KB |
testcase_31 | AC | 90 ms
21,156 KB |
testcase_32 | AC | 90 ms
21,192 KB |
testcase_33 | AC | 74 ms
21,212 KB |
testcase_34 | AC | 89 ms
21,132 KB |
testcase_35 | AC | 84 ms
21,152 KB |
testcase_36 | AC | 91 ms
21,220 KB |
testcase_37 | AC | 76 ms
21,192 KB |
testcase_38 | AC | 123 ms
21,264 KB |
testcase_39 | AC | 124 ms
21,300 KB |
testcase_40 | AC | 125 ms
21,208 KB |
testcase_41 | AC | 74 ms
21,196 KB |
testcase_42 | AC | 122 ms
21,192 KB |
testcase_43 | WA | - |
testcase_44 | WA | - |
testcase_45 | WA | - |
testcase_46 | WA | - |
testcase_47 | WA | - |
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 | AC | 125 ms
21,128 KB |
ソースコード
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for(long long i=0;i<(long long)(n);i++) #define REP(i,k,n) for(long long i=k;i<(long long)(n);i++) #define all(a) a.begin(),a.end() #define rsort(a) {sort(all(a));reverse(all(a));} #define pb emplace_back #define eb emplace_back #define lb(v,k) (lower_bound(all(v),(k))-v.begin()) #define ub(v,k) (upper_bound(all(v),(k))-v.begin()) #define fi first #define se second #define pi M_PI #define PQ(T) priority_queue<T> #define SPQ(T) priority_queue<T,vector<T>,greater<T>> #define dame(a) {out(a);return 0;} #define decimal cout<<fixed<<setprecision(15); #define dupli(a) {sort(all(a));a.erase(unique(all(a)),a.end());} typedef long long ll; typedef pair<ll,ll> P; typedef tuple<ll,ll,ll> PP; typedef tuple<ll,ll,ll,ll> PPP; typedef multiset<ll> S; using vi=vector<ll>; using vvi=vector<vi>; using vvvi=vector<vvi>; using vvvvi=vector<vvvi>; using vp=vector<P>; using vvp=vector<vp>; using vb=vector<bool>; using vvb=vector<vb>; const ll inf=1001001001001001001; const ll INF=1001001001; const ll mod=998244353; const double eps=1e-10; template<class T> bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;} template<class T> bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;} template<class T> void out(T a){cout<<a<<'\n';} template<class T> void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<'\n';} template<class T> void outvp(T v){rep(i,v.size())cout<<'('<<v[i].fi<<','<<v[i].se<<')';cout<<'\n';} template<class T> void outvvp(T v){rep(i,v.size())outvp(v[i]);} template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<'\n';} template<class T> void outvv(T v){rep(i,v.size())outv(v[i]);} template<class T> bool isin(T x,T l,T r){return (l)<=(x)&&(x)<=(r);} template<class T> void yesno(T b){if(b)out("yes");else out("no");} template<class T> void YesNo(T b){if(b)out("Yes");else out("No");} template<class T> void YESNO(T b){if(b)out("YES");else out("NO");} template<class T> void noyes(T b){if(b)out("no");else out("yes");} template<class T> void NoYes(T b){if(b)out("No");else out("Yes");} template<class T> void NOYES(T b){if(b)out("NO");else out("YES");} vi fac,finv,inv; void init(ll n){ n*=3; fac=vi(n+5);finv=vi(n+5);inv=vi(n+5); fac[0] = fac[1] = 1; finv[0] = finv[1] = 1; inv[1] = 1; REP(i,2,n+5){ fac[i]=fac[i-1]*i%mod; inv[i]=mod-inv[mod%i]*(mod/i)%mod; finv[i]=finv[i-1]*inv[i]%mod; } } long long modcom(int n, int k){ if (n < k) return 0; if (n < 0 || k < 0) return 0; return fac[n] * (finv[k] * finv[n - k] % mod) % mod; } ll f(P a,P b){return modcom(b.fi-a.fi+b.se-a.se,b.se-a.se);} int main(){ ll n,m,l,k;cin>>n>>m>>l>>k;init(n); vp checkpoint(m+2);checkpoint[0]=P(0,0);checkpoint[m+1]=P(n,n); rep(i,m)cin>>checkpoint[i+1].fi>>checkpoint[i+1].se; vvp tiger(m+1); ll cnt_tiger=0; rep(i,l){ ll x,y;cin>>x>>y; ll t=lb(checkpoint,P(x,y)); if(checkpoint[t]==P(x,y))k--; else if(checkpoint[t-1].se<=y&&y<=checkpoint[t].se){ tiger[t-1].pb(x,y); cnt_tiger++; } } l=cnt_tiger; chmin(k,l); if(k<0)dame(0); vi dp(k+1,1); rep(i,m+1){ vvi ndp(tiger[i].size(),vi(k+2)); rep(j,ndp.size())rep(t,k+1){ ndp[j][t+1]=dp[t]*f(checkpoint[i],tiger[i][j])%mod; rep(u,j)ndp[j][t+1]-=(ndp[u][t+1]-ndp[u][t])*f(tiger[i][u],tiger[i][j])%mod; ndp[j][t+1]%=mod; ndp[j][t+1]+=mod; ndp[j][t+1]%=mod; } vi tmp(k+1); rep(j,k+1){ tmp[j]=dp[j]*f(checkpoint[i],checkpoint[i+1])%mod; rep(u,ndp.size()){ tmp[j]-=(ndp[u][j+1]-ndp[u][j])*f(tiger[i][u],checkpoint[i+1])%mod; } tmp[j]%=mod; tmp[j]+=mod; tmp[j]%=mod; } dp=tmp; } out(dp[k]); }