結果
| 問題 |
No.506 限られたジャパリまん
|
| コンテスト | |
| ユーザー |
tossy
|
| 提出日時 | 2017-04-21 23:05:49 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 104 ms / 2,000 ms |
| コード長 | 1,305 bytes |
| コンパイル時間 | 1,667 ms |
| コンパイル使用メモリ | 170,188 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-06-28 04:11:20 |
| 合計ジャッジ時間 | 2,936 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 25 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back((a))
#define all(x) (x).begin(),(x).end()
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}
#define INF 2147483600123456
#define MOD 1000000007
long dp[35][35];
int fld[35][35];
int main(){
int h,w,k,p;
cin>>h>>w>>k>>p;
fill(fld[0],fld[35],-1);
vector<string> name(k);
rep(i,k){
int x,y;
cin>>x>>y;
fld[x][y] = i;
cin>>name[i];
}
long mx = -1;
long mmask = -1;
rep(mask,1<<k) if(__builtin_popcount(mask)<=p){
fill(dp[0], dp[35],0);
dp[0][0]=1;
rep(i,h+1)rep(j,w+1)if(fld[i][j]==-1 || (mask&(1<<fld[i][j])) ){
dp[i+1][j] += dp[i][j];
dp[i][j+1] += dp[i][j];
}
if(dp[h][w]>mx){
mx = dp[h][w];
mmask = mask;
}
}
cout << mx%MOD << endl;
rep(i,k) if(mmask&(1<<i)) cout <<name[i] << endl;
return 0;
}
tossy