結果

問題 No.1354 Sambo's Treasure
ユーザー 👑 PCTprobabilityPCTprobability
提出日時 2021-01-15 18:07:52
言語 C++17(clang)
(17.0.6 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 2,491 bytes
コンパイル時間 2,726 ms
コンパイル使用メモリ 167,084 KB
実行使用メモリ 5,484 KB
最終ジャッジ日時 2024-05-07 01:26:52
合計ジャッジ時間 12,075 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 1 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 1 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 1 ms
5,376 KB
testcase_10 AC 2 ms
5,376 KB
testcase_11 AC 1 ms
5,376 KB
testcase_12 AC 2 ms
5,376 KB
testcase_13 AC 2 ms
5,376 KB
testcase_14 AC 2 ms
5,376 KB
testcase_15 AC 2 ms
5,376 KB
testcase_16 AC 2 ms
5,376 KB
testcase_17 AC 2 ms
5,376 KB
testcase_18 AC 2 ms
5,376 KB
testcase_19 AC 2 ms
5,376 KB
testcase_20 AC 1 ms
5,376 KB
testcase_21 AC 2 ms
5,376 KB
testcase_22 AC 1 ms
5,376 KB
testcase_23 RE -
testcase_24 RE -
testcase_25 RE -
testcase_26 RE -
testcase_27 RE -
testcase_28 RE -
testcase_29 RE -
testcase_30 RE -
testcase_31 RE -
testcase_32 RE -
testcase_33 RE -
testcase_34 RE -
testcase_35 RE -
testcase_36 RE -
testcase_37 RE -
testcase_38 RE -
testcase_39 RE -
testcase_40 RE -
testcase_41 RE -
testcase_42 RE -
testcase_43 RE -
testcase_44 RE -
testcase_45 RE -
testcase_46 RE -
testcase_47 RE -
testcase_48 RE -
testcase_49 RE -
testcase_50 RE -
testcase_51 RE -
testcase_52 RE -
testcase_53 RE -
testcase_54 RE -
testcase_55 RE -
testcase_56 RE -
testcase_57 RE -
testcase_58 RE -
testcase_59 RE -
testcase_60 RE -
testcase_61 RE -
testcase_62 RE -
testcase_63 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define all(s) (s).begin(),(s).end()
#define vcin(n) for(ll i=0;i<ll(n.size());i++) cin>>n[i]
#define rever(vec) reverse(vec.begin(), vec.end())
#define sor(vec) sort(vec.begin(), vec.end())
#define fi first
#define se second
const ll mod = 998244353;
//const ll mod = 1000000007;
const ll inf = 2000000000000000000ll;
static const long double pi = 3.141592653589793;
template<class T,class U> void chmax(T& t,const U& u){if(t<u) t=u;}
template<class T,class U> void chmin(T& t,const U& u){if(t>u) t=u;}
ll modPow(ll a, ll n, ll mod) { ll ret = 1; ll p = a % mod; while (n) { if (n & 1) ret = ret * p % mod; p = p * p % mod; n >>= 1; } return ret; }
int main() {
  /* mod は 1e9+7 */
  ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
  cout<< fixed << setprecision(10);
  ll n,m,l,k;
  cin>>n>>m>>l>>k;
  map<pair<ll,ll>,ll> s;
  vector<pair<ll,ll>> h;
  for(int i=0;i<m;i++){
    ll x,y;
    cin>>x>>y;
    pair<ll,ll> z;
    z.fi=x;
    z.se=y;
    h.push_back(z);
  }
  pair<ll,ll> z;
  z.fi=0;
  z.se=0;
  h.push_back(z);
  z.fi=n;
  z.se=n;
  h.push_back(z);
  sor(h);
  for(int i=0;i<l;i++){
    ll x,y;
    cin>>x>>y;
    z.fi=x;
    z.se=y;
    s[z]++;
  }
  ll dp[n+1][n+1][k+1];
  for(int i=0;i<=n;i++){
    for(int j=0;j<=n;j++){
      for(int f=0;f<=k;f++){
        dp[i][j][f]=0;
      }
    }
  }
  dp[0][0][0]=1;
  for(int i=0;i<int(h.size())-1;i++){
    for(int x=h[i].fi;x<=h[i+1].fi;x++){
      for(int y=h[i].se;y<=h[i+1].se;y++){
        if(x==h[i].fi&&y==h[i].se){
          continue;
        }
        pair<ll,ll> r;
        r.fi=x;
        r.se=y;
        assert(s[r]<=1);
        if(s[r]==0){
          if(x!=0){
            for(int e=0;e<=k;e++){
              dp[x][y][e]+=dp[x-1][y][e];
              dp[x][y][e]%=mod;
            }
          }
          if(y!=0){
            for(int e=0;e<=k;e++){
              dp[x][y][e]+=dp[x][y-1][e];
              dp[x][y][e]%=mod;
            }
          }
        }
        else{
          if(x!=0){
            for(int e=1;e<=k;e++){
              dp[x][y][e]+=dp[x-1][y][e-1];
              dp[x][y][e]%=mod;
            }
          }
          if(y!=0){
            for(int e=1;e<=k;e++){
              dp[x][y][e]+=dp[x][y-1][e-1];
              dp[x][y][e]%=mod;
            }
          }
        }
      }
    }
  }
  ll ans=0;
  for(int i=0;i<=k;i++){
    ans+=dp[n][n][i];
    ans%=mod;
  }
  cout<<ans<<endl;
}
0