QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#138146 | #2350. Integer Cow | Delay_for_five_minutes | WA | 9ms | 3492kb | C++20 | 2.0kb | 2023-08-11 01:38:15 | 2023-08-11 01:38:15 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define y0 Y0
int xc , yc , r ,x0 , y0;
const int D = 5e4;
double ans;
int px , py , pr;
long long pf(int x)
{
return 1LL*x*x;
}
bool in_cir(int x,int y)
{
return (pf(x - x0) + pf(y - y0) <= pr);
}
void chk_ans(int x,int y)
{
double sol = sqrt(1LL*x*x + 1LL*y*y);
if(sol < ans) {
ans = sol ;
px = x;py = y;
}
}
const double eps = 1e-6;
void solve()
{
cin >> x0 >> y0 >> r >> xc >> yc;
ans = 1e18; pr = pf(r);
x0 -= xc ; y0 -= yc;
if(1LL * x0*x0 + 1LL*y0*y0 <= 1LL*r*r) {
cout << 0 << '\n';
cout << xc <<' ' << yc << '\n';
return;
}
double ix ;
if(x0 == 0) {
ix = 0 ;
}
else {
double k = (double)y0 / x0;
//cout << k << '\n';
//cout << x0 <<' ' << y0 << '\n';
double a = k*k + 1 , b = -(2*x0 + 2*k*y0) , c = (1LL*x0*x0 + 1LL*y0*y0 - 1LL*r*r) ;
double delta = sqrt(b*b - 4*a*c) ;
//cout << a <<' ' << b <<' ' << c << '\n';
double x1 = (-b + delta) / (2 * a) , x2 = (-b - delta) / (2 * a) ;
if(fabs(x1) < fabs(x2)) ix = x1;
else ix = x2;
}
//cout << ix << '\n';
int R = ix + D;
for(int i = ix - D ; i <= R ; i++) {
double d = 1LL*r*r - 1LL*(i - x0)*(i - x0) ;
if(d < 0) continue;
d = sqrt(d);
double yl = d + y0 , yr = -d + y0;
int ul = yl - 2 - eps , ur = yr + 2 + eps;
if(ul > ur) continue;
for(int x = 0 ; x <= 2 && !in_cir(i , ul);x++) ul++;
for(int x = 0 ; x <= 2 && !in_cir(i , ur);x++) ur--;
// printf("U %d %d\n",ul,ur);
if(ur < 0) chk_ans(i , ur);
else if(ul > 0) chk_ans(i , ul);
else chk_ans(i , 0);
}
cout << 1 << '\n';
cout << xc <<' ' << yc <<' ' << (px + xc) <<' ' << (py + yc) << '\n';
}
int main(){
// freopen("in.txt","r",stdin);
ios::sync_with_stdio(false) ; cin.tie(0) ; cout.tie(0);
int t;cin >> t;
while(t--) solve();
}
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 3464kb
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: 3464kb
input:
1 0 0 1 0 0
output:
0 0 0
result:
ok correct (1 test case)
Test #3:
score: -100
Wrong Answer
time: 9ms
memory: 3492kb
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 2 1 -1 0 1 -2 -2 2 -2 2 -1 -2 1 2 2 -2 2 -1 2 1 -1 2 -2 1 2 -3 -2 -1 1 1 -1 1 2 2 1 1 -3 2 0 1 -2 -1 -1 2 1 -2 0 2 -2 2 -2 -1 -2 -2 1 1 -2 -1 1 2 2 1 2 -3 1 0 -1 -3 -3 2 2 -1 2 1 1 -1 1 -3 -2 1 -2 -3 0 ...
output:
1 -3 -2 -2 -1 1 -2 0 -1 -1 1 0 1 1 -1 1 -1 0 -1 -2 1 -1 -1 -1 1 1 0 -3 0 -2 0 -3 -2 0 2 1 1 -2 -2 -1 -1 1 -1 -2 0 -2 1 -2 2 -1 2 0 -1 2 1 -3 -2 -3 0 0 -1 1 1 1 -3 2 1 1 -2 -1 1 0 1 -2 0 -1 1 1 -2 -1 0 -2 1 1 -2 -1 -2 1 2 1 1 1 1 0 -1 1 -3 1 2 -1 -1 -3 1 -1 1 1 1 1 -2 -3 -3 -3 0 -2 -2 0 -2 -2 0 1 -1 ...
result:
wrong answer the distance of your solution has travelled is longer than expected. (test case 5)