QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#739677 | #7781. Sheep Eat Wolves | Rightt | WA | 1ms | 3956kb | C++20 | 1.4kb | 2024-11-12 22:40:05 | 2024-11-12 22:40:07 |
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();
//if (t++>100) break;
//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: 100
Accepted
time: 0ms
memory: 3708kb
input:
4 4 3 1
output:
3
result:
ok 1 number(s): "3"
Test #2:
score: 0
Accepted
time: 0ms
memory: 3716kb
input:
3 5 2 0
output:
5
result:
ok 1 number(s): "5"
Test #3:
score: 0
Accepted
time: 0ms
memory: 3652kb
input:
2 5 1 1
output:
-1
result:
ok 1 number(s): "-1"
Test #4:
score: 0
Accepted
time: 0ms
memory: 3936kb
input:
1 1 1 0
output:
1
result:
ok 1 number(s): "1"
Test #5:
score: 0
Accepted
time: 0ms
memory: 3708kb
input:
3 3 1 1
output:
7
result:
ok 1 number(s): "7"
Test #6:
score: 0
Accepted
time: 0ms
memory: 3936kb
input:
3 3 2 1
output:
3
result:
ok 1 number(s): "3"
Test #7:
score: 0
Accepted
time: 0ms
memory: 3652kb
input:
10 9 1 10
output:
19
result:
ok 1 number(s): "19"
Test #8:
score: 0
Accepted
time: 0ms
memory: 3708kb
input:
15 20 2 5
output:
27
result:
ok 1 number(s): "27"
Test #9:
score: 0
Accepted
time: 1ms
memory: 3648kb
input:
18 40 16 7
output:
5
result:
ok 1 number(s): "5"
Test #10:
score: 0
Accepted
time: 1ms
memory: 3728kb
input:
60 60 8 1
output:
27
result:
ok 1 number(s): "27"
Test #11:
score: 0
Accepted
time: 1ms
memory: 3712kb
input:
60 60 8 4
output:
27
result:
ok 1 number(s): "27"
Test #12:
score: 0
Accepted
time: 1ms
memory: 3600kb
input:
60 60 8 8
output:
25
result:
ok 1 number(s): "25"
Test #13:
score: 0
Accepted
time: 1ms
memory: 3720kb
input:
60 60 16 1
output:
13
result:
ok 1 number(s): "13"
Test #14:
score: 0
Accepted
time: 1ms
memory: 3956kb
input:
60 60 16 8
output:
11
result:
ok 1 number(s): "11"
Test #15:
score: 0
Accepted
time: 1ms
memory: 3696kb
input:
60 60 16 16
output:
11
result:
ok 1 number(s): "11"
Test #16:
score: 0
Accepted
time: 1ms
memory: 3952kb
input:
60 60 16 24
output:
9
result:
ok 1 number(s): "9"
Test #17:
score: 0
Accepted
time: 1ms
memory: 3716kb
input:
75 15 1 1
output:
175
result:
ok 1 number(s): "175"
Test #18:
score: 0
Accepted
time: 0ms
memory: 3712kb
input:
50 100 1 0
output:
-1
result:
ok 1 number(s): "-1"
Test #19:
score: 0
Accepted
time: 1ms
memory: 3776kb
input:
100 100 10 10
output:
35
result:
ok 1 number(s): "35"
Test #20:
score: 0
Accepted
time: 1ms
memory: 3660kb
input:
100 100 10 1
output:
37
result:
ok 1 number(s): "37"
Test #21:
score: 0
Accepted
time: 1ms
memory: 3956kb
input:
100 100 10 20
output:
33
result:
ok 1 number(s): "33"
Test #22:
score: 0
Accepted
time: 0ms
memory: 3888kb
input:
100 100 10 30
output:
31
result:
ok 1 number(s): "31"
Test #23:
score: 0
Accepted
time: 0ms
memory: 3664kb
input:
100 100 10 80
output:
21
result:
ok 1 number(s): "21"
Test #24:
score: 0
Accepted
time: 1ms
memory: 3752kb
input:
100 100 1 100
output:
199
result:
ok 1 number(s): "199"
Test #25:
score: -100
Wrong Answer
time: 1ms
memory: 3948kb
input:
100 100 5 0
output:
77
result:
wrong answer 1st numbers differ - expected: '95', found: '77'