QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#137444 | #2350. Integer Cow | Team_name# | WA | 2ms | 3452kb | C++20 | 1.0kb | 2023-08-10 12:49:13 | 2023-08-10 12:49:17 |
Judging History
answer
#include <cmath>
#include <iostream>
using LL = long long;
constexpr double inf = 1E18;
LL sqr(int a) { return static_cast<LL>(a) * a; }
void solve()
{
int xc, yc, r, x0, y0; std::cin >> xc >> yc >> r >> x0 >> y0;
auto in = [xc, yc, r](int x, int y) {
if (sqr(x - xc) + sqr(y - yc) <= sqr(r))
return true;
return false;
};
auto dis = [x0, y0](int x, int y) {
return std::sqrt(sqr(x0 - x) + sqr(y0 - y));
};
if (in(x0, y0))
{
std::cout << "0\n";
std::cout << x0 << " " << y0 << "\n";
}
else
{
double k = r / dis(xc, yc);
int x = k * x0 + (1 - k) * xc;
int y = k * y0 + (1 - k) * yc;
double m = inf; int mx, my;
for (int dx = -3; dx <= 3; ++dx)
for (int dy = -3; dy <= 3; ++dy)
{
if (in(x + dx, y + dy))
if (double d = dis(x + dx, y + dy); d < m)
m = d, mx = x + dx, my = y + dy;
}
std::cout << "1\n";
std::cout << x0 << " " << y0 << " " << mx << " " << my << "\n";
}
}
int main()
{
int t; std::cin >> t;
while (t--) solve();
}
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 3424kb
input:
3 1 2 1 1 2 3 2 5 -10 3 0 0 1 10 0
output:
0 1 2 1 -10 3 -2 2 1 10 0 1 0
result:
ok correct (3 test cases)
Test #2:
score: 0
Accepted
time: 1ms
memory: 3336kb
input:
1 0 0 1 0 0
output:
0 0 0
result:
ok correct (1 test case)
Test #3:
score: 0
Accepted
time: 2ms
memory: 3452kb
input:
100 -1 0 2 -3 -2 0 -2 2 -2 0 2 -1 1 0 1 -1 -3 1 -1 0 -1 2 2 -1 -1 2 -2 2 0 -3 -2 -3 2 -3 -2 0 1 2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-3 1 -8 2 -3 -5 1 -1 0 -2 -1 0 -5 5 1 -4 -1 -3 5 1 -3 -7 -10 6 1 2 -3 -5 -3 1 -4 6 -3 6 1 -3 5 1 3 1 9 9 1 9 1 8 -10 2 -2 1 7 -1 5 1 ...
result:
ok correct (100 test cases)
Test #5:
score: -100
Wrong Answer
time: 2ms
memory: 3420kb
input:
100 -52 -13 72 44 58 79 -58 32 60 11 -50 21 75 95 65 -37 -61 21 -74 -40 0 -88 14 11 -49 10 -80 46 79 -17 75 -94 90 61 -34 -80 19 85 -7 -20 -72 42 56 67 -89 21 51 39 20 88 82 32 56 88 -82 3 51 31 -45 -53 50 12 91 9 46 -45 29 25 76 27 -19 -14 81 22 97 5 93 35 98 64 54 90 88 -100 63 -60 -18 81 -20 8 34...
output:
1 44 58 7 28 1 60 11 68 -28 1 95 65 22 42 1 -74 -40 -54 -49 1 11 -49 5 -75 1 79 -17 43 -48 0 61 -34 0 -7 -20 1 67 -89 -30 5 0 20 88 1 88 -82 82 -24 1 -45 -53 -10 23 0 9 46 1 76 27 -20 29 1 22 97 9 62 1 98 64 39 85 1 -100 63 -33 77 0 -20 8 1 62 16 46 51 1 -46 66 -79 -27 1 62 -91 -11 -54 1 -55 -54 73 ...
result:
wrong answer the distance of your solution has travelled is longer than expected. (test case 33)