QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#655165#7781. Sheep Eat WolvesenarWA 0ms3680kbC++201.1kb2024-10-19 01:04:322024-10-19 01:04:33

Judging History

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

  • [2024-10-19 01:04:33]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3680kb
  • [2024-10-19 01:04:32]
  • 提交

answer

#include <bits/stdc++.h>
using i64 = long long;
const int INF = 1E4;

void solve() {
    int x, y, p, q;
    std::cin >> x >> y >> p >> q;
    std::vector dp(2, std::vector(x + 1, std::vector<int>(y + 1, INF)));
    dp[0][0][0] = dp[1][x][y] = 0;
    int opt = 0;
    for(int t = 0; t <= 200; ++t, opt ^= 1) {
        for(int i = 0; i <= p; ++i) { 
            for(int j = 0; j <= p - i; ++j) { 
                for(int a = i; a <= x; ++a) { 
                    for(int b = (a == x ? j : std::max(j, y - x + a - q)); b <= y; ++b) {
                        dp[opt][a][b] = std::min(dp[opt][a][b], dp[opt ^ 1][x - a + i][y - b + j] + 1); 
                    }
                }
            }
        }
        int mn = INF;
        for(int i = 0; i <= y; ++i) {
            mn = std::min(mn, dp[0][x][i]);
        }
        if(mn != INF) {
            std::cout << mn << '\n';
            return;
        }
    }   
}

int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    int T = 1;
    // std::cin >> T;
    while(T--) {
        solve();
    }
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3628kb

input:

4 4 3 1

output:

3

result:

ok 1 number(s): "3"

Test #2:

score: 0
Accepted
time: 0ms
memory: 3680kb

input:

3 5 2 0

output:

5

result:

ok 1 number(s): "5"

Test #3:

score: -100
Wrong Answer
time: 0ms
memory: 3564kb

input:

2 5 1 1

output:


result:

wrong answer Answer contains longer sequence [length = 1], but output contains 0 elements