QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#768696#7781. Sheep Eat Wolvesucup-team5217#WA 0ms3896kbC++23957b2024-11-21 13:44:572024-11-21 13:44:57

Judging History

你现在查看的是最新测评结果

  • [2024-11-21 13:44:57]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3896kb
  • [2024-11-21 13:44:57]
  • 提交

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'