QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#825044 | #9770. Middle Point | ucup-team4435# | WA | 0ms | 3788kb | C++20 | 1.6kb | 2024-12-21 17:05:59 | 2024-12-21 17:06:00 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
auto work = [&](int A, int X) -> vector<pair<int, int>> {
if (A == X || A == 0) {
return {};
}
int p = 1;
while (A % 2 == 0) {
p *= 2;
A /= 2;
}
int f = A;
if (X % f != 0) {
return {{-1, -1}};
}
X /= f;
A = p;
vector<pair<int, int>> o;
int l = 0, r = A;
while (l != X && r != X) {
int mid = l + r >> 1;
o.push_back({l, r});
if (mid == X) {
break;
} else if (mid > X) {
r = mid;
} else {
l = mid;
}
}
for (auto &[x, y]: o) {
x *= f, y *= f;
}
return o;
};
int A, B, X, Y;
cin >> A >> B >> X >> Y;
auto a = work(A, X), b = work(B, Y);
if (!a.empty() && a[0].first == -1 || !b.empty() && b[0].first == -1) {
cout << "-1\n";
return 0;
}
int i = 0;
cout << max(a.size(), b.size()) << '\n';
while (i < a.size() || i < b.size()) {
int x1 = X, y1 = Y, x2 = X, y2 = Y;
if (i < a.size()) {
x1 = a[i].first, x2 = a[i].second;
}
if (i < b.size()) {
y1 = b[i].first, y2 = b[i].second;
}
i += 1;
cout << x1 << " " << y1 << " " << x2 << " " << y2 << '\n';
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3612kb
input:
2 2 1 1
output:
1 0 0 2 2
result:
ok correct!
Test #2:
score: 0
Accepted
time: 0ms
memory: 3788kb
input:
8 8 5 0
output:
3 0 0 8 0 4 0 8 0 4 0 6 0
result:
ok correct!
Test #3:
score: 0
Accepted
time: 0ms
memory: 3564kb
input:
0 0 0 0
output:
0
result:
ok correct!
Test #4:
score: 0
Accepted
time: 0ms
memory: 3600kb
input:
2024 0 1012 0
output:
1 0 0 2024 0
result:
ok correct!
Test #5:
score: 0
Accepted
time: 0ms
memory: 3536kb
input:
2024 2024 2023 2023
output:
-1
result:
ok correct!
Test #6:
score: -100
Wrong Answer
time: 0ms
memory: 3584kb
input:
8 6 7 3
output:
3 0 0 8 6 4 3 8 3 6 3 8 3
result:
wrong answer (8,3) is not in S