QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#764338 | #7781. Sheep Eat Wolves | fosov | WA | 0ms | 3716kb | C++14 | 1.4kb | 2024-11-20 08:46:31 | 2024-11-20 08:46:50 |
Judging History
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 main() {
#ifdef TEST
freopen("zz.in", "r+", stdin);
#endif
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cout << setprecision(18);
int x, y, p, q; cin >> x >> y >> p >> q;
int sx = 0, sy = 0;
y -= sy;
int tx = 0, ty = 0;
int d = INF, stp = 0, f = 1;
auto trans = [&](int& x, int& y, int d) {
x += d, y -= d;
};
while (stp < 10) {
f &= p-sx-sy>=y-(x+q);
trans(sy, y, max(0, y-(x+q)));
trans(sx, x, min(p-sx-sy, max(0, x-(y-q))));
d = min((p-sx-sy)/2, min(x, y));
trans(sx, x, d);
trans(sy, y, d);
if (p-sx>=x) {
trans(y, sy, sy);
trans(sx, x, x);
}
++ stp;
trans(tx, sx, sx);
trans(ty, sy, sy);
if (x == 0) break;
if (tx) {
f &= p-sx-sy>=ty-(tx+q);
trans(sy, ty, max(0, ty-(tx+q)));
}
++ stp;
}
cout << (!f || stp == int(1e5) ? -1 : stp) << '\n';
}
// 3 3
// 2 2
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3716kb
input:
4 4 3 1
output:
3
result:
ok 1 number(s): "3"
Test #2:
score: 0
Accepted
time: 0ms
memory: 3580kb
input:
3 5 2 0
output:
5
result:
ok 1 number(s): "5"
Test #3:
score: 0
Accepted
time: 0ms
memory: 3660kb
input:
2 5 1 1
output:
-1
result:
ok 1 number(s): "-1"
Test #4:
score: 0
Accepted
time: 0ms
memory: 3596kb
input:
1 1 1 0
output:
1
result:
ok 1 number(s): "1"
Test #5:
score: -100
Wrong Answer
time: 0ms
memory: 3660kb
input:
3 3 1 1
output:
10
result:
wrong answer 1st numbers differ - expected: '7', found: '10'