QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#764472#7781. Sheep Eat WolvesfosovWA 0ms3596kbC++141.3kb2024-11-20 09:18:412024-11-20 09:18:41

Judging History

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

  • [2024-11-20 09:18:41]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3596kb
  • [2024-11-20 09:18:41]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

#define ll long long 
#define lll __int128
#define INF 0x3f3f3f3f
#define LNF 0x3f3f3f3f3f3f3f3fll
#define MOD 998244353
#define pii pair<int, int>
#define ld long double
#define fi first
#define se second
#define all(a) a.begin(), a.end()

#define N 110

int vis[N][N][2], dis[N][N][2];

int main() {
#ifdef TEST
    freopen("zz.in", "r+", stdin);
#endif
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    
    int x, y, p, q; cin >> x >> y >> p >> q;
    queue<tuple<int, int, int>> s;
    s.emplace(x, y, 1);
    dis[x][y][1] = 0;

    while (!s.empty()) {
        auto [cx, cy, cd] = s.front(); s.pop();

        for (int sx = 0; sx <= cx; ++ sx) {
            for (int sy = 0; sy <= cy; ++ sy) {
                if (sx + sy > p) continue;
                int nx = cx - sx;
                int ny = cy - sy;
                if (nx+q<ny) continue;
                if (vis[nx][ny][cd^1]) continue;
                vis[nx][ny][cd^1] = 1;
                dis[nx][ny][cd^1] = dis[cx][cy][cd] + 1;
                s.emplace(nx, ny, cd^1);
            }
        }
    }   

    int res = INF;
    for (int i = 0; i <= y; ++ i) if (vis[0][i][0]) res = min(res, dis[0][i][0]);

    cout << (res == INF ? -1 : res) << '\n';
}   

// 3 3
// 2 2

详细

Test #1:

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

input:

4 4 3 1

output:

3

result:

ok 1 number(s): "3"

Test #2:

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

input:

3 5 2 0

output:

5

result:

ok 1 number(s): "5"

Test #3:

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

input:

2 5 1 1

output:

-1

result:

ok 1 number(s): "-1"

Test #4:

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

input:

1 1 1 0

output:

3

result:

wrong answer 1st numbers differ - expected: '1', found: '3'