QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#768696 | #7781. Sheep Eat Wolves | ucup-team5217# | WA | 0ms | 3896kb | C++23 | 957b | 2024-11-21 13:44:57 | 2024-11-21 13:44:57 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
const int N = 110;
int n, m, p, q;
int f[N][N];
int main() {
scanf("%d%d%d%d", &n, &m, &p, &q);
memset(f, 0x3f, sizeof(f));
f[n][m] = 0;
for (int i = n; ~i; --i) {
for (int j = m; ~j; --j) {
if (i == 0 && j == 0) continue;
for (int k = 0; k <= min(i, p); ++k) {
int _k = min(j, p - k);
for (int l = 0; l <= min(p, (m - (j - _k))); ++l) {
if ((i - k == 0 && j - _k + l == 0) || ((i - k + q >= j - _k || i - k == 0) && ((n - i + k) + q >= (m - (j - _k)) - l || (n - i + k) == 0))) {
f[i - k][j - _k + l] = min(f[i - k][j - _k + l], f[i][j] + 1);
}
}
}
}
}
// cerr << f[0][100] << '\n';
if (f[0][0] == 0x3f3f3f3f) {
f[0][0] = -1;
}
printf("%d\n", f[0][0]);
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3896kb
input:
4 4 3 1
output:
3
result:
ok 1 number(s): "3"
Test #2:
score: 0
Accepted
time: 0ms
memory: 3796kb
input:
3 5 2 0
output:
5
result:
ok 1 number(s): "5"
Test #3:
score: 0
Accepted
time: 0ms
memory: 3824kb
input:
2 5 1 1
output:
-1
result:
ok 1 number(s): "-1"
Test #4:
score: -100
Wrong Answer
time: 0ms
memory: 3892kb
input:
1 1 1 0
output:
2
result:
wrong answer 1st numbers differ - expected: '1', found: '2'