QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#137516#2350. Integer Cowwhsyhyyh#WA 98ms3880kbC++201.8kb2023-08-10 13:39:552023-08-10 13:39:57

Judging History

你现在查看的是最新测评结果

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-08-10 13:39:57]
  • 评测
  • 测评结果:WA
  • 用时:98ms
  • 内存:3880kb
  • [2023-08-10 13:39:55]
  • 提交

answer

#pragma GCC optimize("Ofast","unroll-loops","omit-frame-pointer","inline")
#pragma GCC option("arch=native","tune=native","no-zero-upper")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2")
#pragma GCC optimize(3)
#include<bits/stdc++.h>
#define eps 1e-8
#define inf 1000000000000000000.0
#define rep(i,l,r) for(int i=l;i<=r;i++)
#define drep(i,r,l) for(int i=r;i>=l;i--)
#define ll long long 
using namespace std;
ll rd() {
	ll res=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9') {if(ch=='-') f*=-1;ch=getchar();}
	while(ch>='0'&&ch<='9') res=(res<<1)+(res<<3)+(ch^48),ch=getchar();
	return res*f;
}
ll T,Xc,Yc,R,X0,Y0;
ll x,y;ll ansx,ansy;
ll ans;
long double dist(ll x,ll y,ll xx,ll yy) {
	return sqrt((long double)(x-xx)*(x-xx)+(long double)(y-yy)*(y-yy));
}
void work(ll i,ll j) {
	ll tmpx=(ll) ceil(x)+i;
	ll tmpy=(ll) ceil(y)+j;
	if(1LL*(tmpx-Xc)*(tmpx-Xc)+1LL*(tmpy-Yc)*(tmpy-Yc)<=1LL*R*R) {
//		double dis=dist(tmpx,tmpy,X0,Y0);
		if(ans==-1||1LL*(tmpx-X0)*(tmpx-X0)+1LL*(tmpy-Y0)*(tmpy-Y0)<ans) 
			ans=1LL*(tmpx-X0)*(tmpx-X0)+1LL*(tmpy-Y0)*(tmpy-Y0),ansx=tmpx,ansy=tmpy;
	}
}
int main() {
	T=rd();
	ll sz=sqrt(50000000/T);
	while(T--) {
		Xc=rd(),Yc=rd(),R=rd(),X0=rd(),Y0=rd();
		if(1LL*(X0-Xc)*(X0-Xc)+1LL*(Y0-Yc)*(Y0-Yc)<=1LL*R*R) {
			printf("0\n%d %d\n",X0,Y0);
			continue;
		}
		ll l=min(X0,Xc),r=max(X0,Xc);
		while(l<=r){
			ll mid=(l+r)>>1;
			y=Yc+(long double)(Y0-Yc)/(long double)(X0-Xc)*(mid-Xc);
			if((y-Yc)*(y-Yc)+(mid-Xc)*(mid-Xc)<=R){
				if(X0<Xc) r=mid-1;
				else l=mid+1;
				x=mid;
			}
			else{
				if(X0<Xc) l=mid+1;
				else r=mid-1;
			}
		}
		y=Yc+(long double)(Y0-Yc)/(long double)(X0-Xc)*(x-Xc);
		ans=-1;
		rep(i,-sz,sz) rep(j,-sz,sz) work(i,j);
		
		printf("1\n%lld %lld %lld %lld\n",X0,Y0,ansx,ansy);
	}
	return 0;
}

详细

Test #1:

score: 100
Accepted
time: 85ms
memory: 3664kb

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: 0ms
memory: 3880kb

input:

1
0 0 1 0 0

output:

0
0 0

result:

ok correct (1 test case)

Test #3:

score: -100
Wrong Answer
time: 98ms
memory: 3572kb

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 9223372036854775806
1
-1 -1 -1 -9223372036854775808
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 -2 -1
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
...

result:

wrong output format Expected int32, but "9223372036854775806" found (test case 4)