結果
| 問題 |
No.1354 Sambo's Treasure
|
| コンテスト | |
| ユーザー |
PCTprobability
|
| 提出日時 | 2021-01-15 18:07:52 |
| 言語 | C++17(clang) (17.0.6 + boost 1.87.0) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 2,491 bytes |
| コンパイル時間 | 6,569 ms |
| コンパイル使用メモリ | 165,632 KB |
| 実行使用メモリ | 6,824 KB |
| 最終ジャッジ日時 | 2024-11-29 13:14:23 |
| 合計ジャッジ時間 | 11,728 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 20 RE * 41 |
ソースコード
#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;
}
PCTprobability