QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#770195 | #9770. Middle Point | PlentyOfPenalty# | WA | 1ms | 3728kb | C++20 | 1.9kb | 2024-11-21 21:03:28 | 2024-11-21 21:03:28 |
Judging History
answer
#include <bits/stdc++.h>
#define sz(x) ((int)(x).size())
#define all(x) begin(x), end(x)
#ifdef memset0
#define log(...) fprintf(stderr, __VA_ARGS__)
#else
#define endl '\n'
#define log(...) (void(0))
#endif
using namespace std;
using ll = long long;
using lf = long double;
using ull = unsigned long long;
using lll = __int128;
set<pair<int, int>> s;
vector<pair<int, int>> vec;
int a, b, a1, b1, a2, b2;
pair<int, int> get_lu(int x, int m) {
if (x == 0) return make_pair(0, 0);
if (x == m) return make_pair(m, m);
int y = x & -x;
return make_pair(x - y, x + y);
}
void search(int x, int y) {
if (s.count(make_pair(x, y))) {
return;
}
log("> search %d %d\n", x, y);
s.insert(make_pair(x, y));
auto [x1, x2] = get_lu(x, a2);
auto [y1, y2] = get_lu(y, b2);
log("! %d %d %d %d\n", x1, y1, x2, y2);
if (x1 == 0 && y2 == b2) {
swap(y1, y2);
}
search(x1, y1);
search(x2, y2);
vec.emplace_back(x, y);
}
int main() {
#ifdef memset0
freopen("C.in", "r", stdin);
#endif
cin.tie(0)->sync_with_stdio(0);
cin >> a >> b;
if (a) {
a1 = a, a2 = 1;
while (a1 % 2 == 0) a1 >>= 1, a2 <<= 1;
} else {
a1 = 1, a2 = 0;
}
if (b) {
b1 = b, b2 = 1;
while (b1 % 2 == 0) b1 >>= 1, b2 <<= 1;
} else {
b1 = 1, b2 = 0;
}
log(">> %d %d %d %d\n", a1, b1, a2, b2);
int x, y;
cin >> x >> y;
if (x % a1 || y % b1) {
cout << -1 << endl;
return 0;
}
x /= a1;
y /= b1;
s.insert(make_pair(0, 0));
s.insert(make_pair(a2, 0));
s.insert(make_pair(0, b2));
s.insert(make_pair(a2, b2));
search(x, y);
// reverse(all(vec));
cout << sz(vec) << endl;
for (auto [x, y] : vec) {
auto [x1, x2] = get_lu(x, a2);
auto [y1, y2] = get_lu(y, b2);
cout << x1 * a1 << ' ' << y1 * b1 << ' ' << x2 * a1 << ' ' << y2 * b1 << endl;
}
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3728kb
input:
2 2 1 1
output:
1 0 0 2 2
result:
ok correct!
Test #2:
score: 0
Accepted
time: 0ms
memory: 3632kb
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: 3648kb
input:
0 0 0 0
output:
0
result:
ok correct!
Test #4:
score: 0
Accepted
time: 1ms
memory: 3644kb
input:
2024 0 1012 0
output:
1 0 0 2024 0
result:
ok correct!
Test #5:
score: 0
Accepted
time: 0ms
memory: 3592kb
input:
2024 2024 2023 2023
output:
-1
result:
ok correct!
Test #6:
score: 0
Accepted
time: 0ms
memory: 3584kb
input:
8 6 7 3
output:
3 0 0 8 0 4 0 8 0 6 0 8 6
result:
ok correct!
Test #7:
score: 0
Accepted
time: 0ms
memory: 3524kb
input:
2024 2026 2024 2026
output:
0
result:
ok correct!
Test #8:
score: 0
Accepted
time: 0ms
memory: 3664kb
input:
1000000000 1000000000 70 0
output:
-1
result:
ok correct!
Test #9:
score: 0
Accepted
time: 0ms
memory: 3592kb
input:
3 6 2 4
output:
-1
result:
ok correct!
Test #10:
score: 0
Accepted
time: 0ms
memory: 3672kb
input:
7 7 7 2
output:
-1
result:
ok correct!
Test #11:
score: 0
Accepted
time: 0ms
memory: 3588kb
input:
6 2 5 2
output:
-1
result:
ok correct!
Test #12:
score: 0
Accepted
time: 0ms
memory: 3648kb
input:
5 7 5 5
output:
-1
result:
ok correct!
Test #13:
score: 0
Accepted
time: 0ms
memory: 3584kb
input:
4 7 2 3
output:
-1
result:
ok correct!
Test #14:
score: 0
Accepted
time: 0ms
memory: 3652kb
input:
8 2 2 2
output:
2 0 2 8 2 0 2 4 2
result:
ok correct!
Test #15:
score: 0
Accepted
time: 0ms
memory: 3712kb
input:
3 3 0 2
output:
-1
result:
ok correct!
Test #16:
score: 0
Accepted
time: 0ms
memory: 3724kb
input:
7 7 1 4
output:
-1
result:
ok correct!
Test #17:
score: 0
Accepted
time: 0ms
memory: 3664kb
input:
6 3 6 1
output:
-1
result:
ok correct!
Test #18:
score: 0
Accepted
time: 0ms
memory: 3720kb
input:
4 2 2 1
output:
1 0 0 4 2
result:
ok correct!
Test #19:
score: 0
Accepted
time: 0ms
memory: 3676kb
input:
7 2 3 2
output:
-1
result:
ok correct!
Test #20:
score: 0
Accepted
time: 0ms
memory: 3672kb
input:
2 7 0 3
output:
-1
result:
ok correct!
Test #21:
score: 0
Accepted
time: 0ms
memory: 3568kb
input:
1 7 1 0
output:
0
result:
ok correct!
Test #22:
score: 0
Accepted
time: 0ms
memory: 3520kb
input:
5 1 0 0
output:
0
result:
ok correct!
Test #23:
score: 0
Accepted
time: 0ms
memory: 3636kb
input:
8 7 4 3
output:
-1
result:
ok correct!
Test #24:
score: 0
Accepted
time: 0ms
memory: 3632kb
input:
180057652 674822131 110693180 428023738
output:
-1
result:
ok correct!
Test #25:
score: 0
Accepted
time: 0ms
memory: 3592kb
input:
62347541 812142018 42922107 486416913
output:
-1
result:
ok correct!
Test #26:
score: 0
Accepted
time: 0ms
memory: 3704kb
input:
239604722 244429197 78993837 108804105
output:
-1
result:
ok correct!
Test #27:
score: 0
Accepted
time: 0ms
memory: 3584kb
input:
416861903 381749084 375027630 373683256
output:
-1
result:
ok correct!
Test #28:
score: 0
Accepted
time: 0ms
memory: 3640kb
input:
594119084 519068971 429116021 298715088
output:
-1
result:
ok correct!
Test #29:
score: -100
Wrong Answer
time: 0ms
memory: 3600kb
input:
536870912 536870912 233225286 372408647
output:
179 0 0 536870912 0 0 0 268435456 0 134217728 0 268435456 0 201326592 0 268435456 0 201326592 0 234881024 0 218103808 0 234881024 0 0 536870912 536870912 536870912 0 536870912 268435456 536870912 134217728 536870912 268435456 536870912 201326592 536870912 268435456 536870912 226492416 0 234881024 53...
result:
wrong answer Jury has a better answer