QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#739695 | #7781. Sheep Eat Wolves | Rightt | WA | 0ms | 3868kb | C++20 | 1.4kb | 2024-11-12 22:43:01 | 2024-11-12 22:43:02 |
Judging History
answer
#include <bits/stdc++.h>
#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
using ll = long long;
const int N = 100 + 10;
int f[N][N][2];
using t4 = tuple<int, int, int, int>;
void solve(){
int X, Y, P, q;
cin >> X >> Y >> P >> q;
memset(f, 0x3f, sizeof f);
f[X][Y][0] = 0; //0左侧
priority_queue<t4, vector<t4>, greater<t4>> q4;
q4.push(make_tuple(0, X, Y, 0));
int t = 0;
while (!q4.empty()){
auto [d, x, y, k] = q4.top();
cout << d << ' ' << x << ' ' << y << ' ' << k << '\n';
q4.pop();
if (k == 1){
if (f[x][y][0] == 0x3f3f3f3f){
f[x][y][0] = d + 1;
q4.push(make_tuple(d + 1, x, y, 0));
}
}else{
for (int i = 0; i <= min(y, P); i ++ ){
int ty = i;
int tx = min(P - i, x);
if (y - ty - (x - tx) > q && x - tx > 0) continue;
if (f[x-tx][y-ty][1] != 0x3f3f3f3f) continue;
f[x-tx][y-ty][1] = d+1;
q4.push(make_tuple(d+1, x-tx, y-ty, 1));
}
}
}
int mi = 0x3f3f3f3f;
for (int j = 0; j <= Y; j ++ ) mi = min(mi, f[0][j][1]);
if (mi == 0x3f3f3f3f) mi = -1;
cout << mi;
}
signed main(){
IOS;
int t = 1;
// cin >> t;
while (t -- ){
solve();
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3868kb
input:
4 4 3 1
output:
0 4 4 0 1 2 3 1 1 3 2 1 1 4 1 1 2 2 3 0 2 3 2 0 2 4 1 0 3 0 2 1 3 0 3 1 3 1 1 1 3 2 0 1 4 0 2 0 4 0 3 0 4 1 1 0 4 2 0 0 5 0 0 1 5 0 1 1 6 0 0 0 6 0 1 0 3
result:
wrong answer 1st numbers differ - expected: '3', found: '0'