結果
| 問題 |
No.506 限られたジャパリまん
|
| コンテスト | |
| ユーザー |
vjudge1
|
| 提出日時 | 2025-01-28 23:18:03 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,154 bytes |
| コンパイル時間 | 2,127 ms |
| コンパイル使用メモリ | 165,556 KB |
| 実行使用メモリ | 6,824 KB |
| 最終ジャッジ日時 | 2025-01-28 23:18:06 |
| 合計ジャッジ時間 | 3,026 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | WA * 25 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:45:21: warning: format ‘%lld’ expects argument of type ‘long long int’, but argument 2 has type ‘int’ [-Wformat=]
45 | printf ("%lld\n", ans);
| ~~~^ ~~~
| | |
| | int
| long long int
| %d
main.cpp:20:17: warning: ignoring return value of ‘FILE* freopen(const char*, const char*, FILE*)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
20 | freopen ("kart.in", "r", stdin); freopen ("kart.out", "w", stdout);
| ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
main.cpp:20:50: warning: ignoring return value of ‘FILE* freopen(const char*, const char*, FILE*)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
20 | freopen ("kart.in", "r", stdin); freopen ("kart.out", "w", stdout);
| ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
main.cpp:21:15: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
21 | scanf ("%d%d%d%d", &n, &m, &k, &p);
| ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
ソースコード
# include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// # define int long long
# define lc u << 1
# define rc u << 1 | 1
# define fi first
# define se second
const int N = 55, mod = 1e9 + 7;
int n, m, k, p;
struct node
{
int x, y;
string nm;
} a[N];
int f[N][N];
signed main ()
{
freopen ("kart.in", "r", stdin); freopen ("kart.out", "w", stdout);
scanf ("%d%d%d%d", &n, &m, &k, &p);
for (int i = 0; i < k; i ++ ) cin >> a[i].x >> a[i].y >> a[i].nm;
int ans = 0; vector <int> res;
for (int s = 0; s < (1 << k); s ++ )
{
if (__builtin_popcount (s) != p) continue;
memset (f, 0, sizeof f);
vector <int> chs;
for (int i = 0; i < k; i ++ )
{
if (!(s >> i & 1)) f[a[i].x][a[i].y] = -1;
else chs.push_back (i);
}
f[0][0] = 1;
for (int i = 0; i <= n + 1; i ++ )
{
for (int j = 0; j <= m + 1; j ++ )
{
if (i >= 1 && f[i - 1][j] != -1) f[i][j] = (f[i][j] + f[i - 1][j]) % mod;
if (j >= 1 && f[i][j - 1] != -1) f[i][j] = (f[i][j] + f[i][j - 1]) % mod;
}
}
if (ans < f[n][m]) ans = f[n][m] % mod, res = chs;
}
printf ("%lld\n", ans);
for (auto x : res) cout << a[x].nm << "\n";
return 0;
}
vjudge1