QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#764477#7781. Sheep Eat WolvesfosovWA 0ms3792kbC++141.3kb2024-11-20 09:19:242024-11-20 09:19:25

Judging History

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

  • [2024-11-20 09:19:25]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3792kb
  • [2024-11-20 09:19:24]
  • 提交

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&&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

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

4 4 3 1

output:

3

result:

ok 1 number(s): "3"

Test #2:

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

input:

3 5 2 0

output:

3

result:

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