結果
| 問題 |
No.506 限られたジャパリまん
|
| コンテスト | |
| ユーザー |
tkmst201
|
| 提出日時 | 2017-04-23 13:19:41 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,319 bytes |
| コンパイル時間 | 1,383 ms |
| コンパイル使用メモリ | 161,184 KB |
| 実行使用メモリ | 6,948 KB |
| 最終ジャッジ日時 | 2024-06-28 04:16:40 |
| 合計ジャッジ時間 | 2,814 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 12 WA * 13 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:56:18: warning: format ‘%d’ expects argument of type ‘int’, but argument 2 has type ‘long long int’ [-Wformat=]
56 | printf("%d\n", ans.first % MOD);
| ~^ ~~~~~~~~~~~~~~~
| | |
| int long long int
| %lld
ソースコード
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const ll INF = 1ll<<60;
const ll MOD = 1000000007;
const double EPS = 1e-10;
int H, W, K, P;
int x[15], y[15];
string name[15];
bool done[33][33];
ll dp[33][33];
int main() {
cin >> W >> H >> K >> P;
REP(i, K) cin >> x[i] >> y[i] >> name[i];
pii ans = pii(-1, 0); // 数, 集合
REP(s, 1<<K) {
int cnt = 0;
REP(i, K) if (s >> i & 1) cnt++;
if (cnt > P) continue;
memset(done, 0, sizeof(done));
REP(i, K) if (!(s >> i & 1)) done[y[i]][x[i]] = true;
memset(dp, 0, sizeof(dp));
dp[0][0] = !done[0][0];
REP(i, H + 1) REP(j, W + 1) {
if (done[i][j]) continue;
if (i > 0) dp[i][j] += dp[i - 1][j];
if (j > 0) dp[i][j] += dp[i][j - 1];
}
chmax(ans, pii(dp[H][W], s));
}
printf("%d\n", ans.first % MOD);
REP(i, K) if (ans.second >> i & 1) printf("%s\n", name[i].c_str());
return 0;
}
tkmst201