QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#655165 | #7781. Sheep Eat Wolves | enar | WA | 0ms | 3680kb | C++20 | 1.1kb | 2024-10-19 01:04:32 | 2024-10-19 01:04:33 |
Judging History
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