QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#757666 | #7781. Sheep Eat Wolves | CUHK_723 | WA | 13ms | 7536kb | C++14 | 1.3kb | 2024-11-17 11:59:05 | 2024-11-17 11:59:05 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
inline int read() {
int x = 0, f = 1;
char ch = getchar();
while(ch < '0' || ch > '9') {
if(ch == '-') f = -1;
ch = getchar();
}
while(ch >= '0' && ch <= '9') {
x = (x << 1) + (x << 3) + (ch ^ 48);
ch = getchar();
}
return x * f;
}
int x, y, p, q;
bool vis[110][110][110];
int ans = 10000;
struct Node {
int a, b, c, t;
};
void solve() {
queue<Node> s;
s.push({x, y, 0, 0});
while(!s.empty()) {
Node tmp = s.front();
s.pop();
int a = tmp.a, b = tmp.b, c = tmp.c, t = tmp.t;
if(a < 0 || b < 0 || t > 100 || a > x || b > y) continue;
if(vis[a][b][t]) continue;
vis[a][b][t] = 1;
//cout << a << " " << b << " " << c << " " << t << endl;
if(c == 0) {
if(a <= p) {
cout << t + 1;
return;
}
for(int i = 0; i <= p; ++i) { //i羊
for(int j = 0; j <= p - i; ++j) {
if(a - i + q < b - j) continue;
s.push({a - i, b - j, 1, t + 1});
}
}
}
else {
//cout << p << endl;
for(int i = 0; i <= p; ++i) { //i羊
for(int j = 0; j <= p - i; ++j) {
if(x - a - i + q < y - b - j && x - a - i >= 1) continue;
s.push({a + i, b + j, 0, t + 1});
}
}
}
}
cout << -1;
return;
}
int main() {
x = read();
y = read();
p = read();
q = read();
solve();
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3576kb
input:
4 4 3 1
output:
3
result:
ok 1 number(s): "3"
Test #2:
score: 0
Accepted
time: 0ms
memory: 3556kb
input:
3 5 2 0
output:
5
result:
ok 1 number(s): "5"
Test #3:
score: 0
Accepted
time: 0ms
memory: 3608kb
input:
2 5 1 1
output:
-1
result:
ok 1 number(s): "-1"
Test #4:
score: 0
Accepted
time: 0ms
memory: 3624kb
input:
1 1 1 0
output:
1
result:
ok 1 number(s): "1"
Test #5:
score: 0
Accepted
time: 0ms
memory: 3636kb
input:
3 3 1 1
output:
7
result:
ok 1 number(s): "7"
Test #6:
score: 0
Accepted
time: 0ms
memory: 3504kb
input:
3 3 2 1
output:
3
result:
ok 1 number(s): "3"
Test #7:
score: 0
Accepted
time: 0ms
memory: 3696kb
input:
10 9 1 10
output:
19
result:
ok 1 number(s): "19"
Test #8:
score: 0
Accepted
time: 0ms
memory: 3660kb
input:
15 20 2 5
output:
27
result:
ok 1 number(s): "27"
Test #9:
score: 0
Accepted
time: 1ms
memory: 3896kb
input:
18 40 16 7
output:
5
result:
ok 1 number(s): "5"
Test #10:
score: 0
Accepted
time: 3ms
memory: 4196kb
input:
60 60 8 1
output:
27
result:
ok 1 number(s): "27"
Test #11:
score: 0
Accepted
time: 5ms
memory: 4468kb
input:
60 60 8 4
output:
27
result:
ok 1 number(s): "27"
Test #12:
score: 0
Accepted
time: 6ms
memory: 4652kb
input:
60 60 8 8
output:
25
result:
ok 1 number(s): "25"
Test #13:
score: 0
Accepted
time: 7ms
memory: 5448kb
input:
60 60 16 1
output:
13
result:
ok 1 number(s): "13"
Test #14:
score: 0
Accepted
time: 10ms
memory: 6300kb
input:
60 60 16 8
output:
11
result:
ok 1 number(s): "11"
Test #15:
score: 0
Accepted
time: 13ms
memory: 7336kb
input:
60 60 16 16
output:
11
result:
ok 1 number(s): "11"
Test #16:
score: 0
Accepted
time: 11ms
memory: 7536kb
input:
60 60 16 24
output:
9
result:
ok 1 number(s): "9"
Test #17:
score: -100
Wrong Answer
time: 1ms
memory: 4092kb
input:
75 15 1 1
output:
-1
result:
wrong answer 1st numbers differ - expected: '175', found: '-1'