QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#137495#2350. Integer Cowwhsyhyyh#TL 1972ms3604kbC++202.0kb2023-08-10 13:29:022023-08-10 13:29:05

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:29:05]
  • 评测
  • 测评结果:TL
  • 用时:1972ms
  • 内存:3604kb
  • [2023-08-10 13:29:02]
  • 提交

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(100000000/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;
		}
		long double tmpx=(long double)R*(long double)abs(X0-Xc)/dist(X0,Y0,Xc,Yc);
		long double tmpy=sqrt(R*R-(long double)tmpx*(long double)tmpx);
		ans=-1;
		if(X0<Xc) x=Xc-tmpx;else x=Xc+tmpx;
		if(Y0<Yc) y=Yc-tmpy;else y=Yc+tmpy;
		rep(i,-sz,sz) rep(j,-sz,sz) work(i,j);
		
		if(X0<Xc) x=Xc+tmpx;else x=Xc-tmpx;
		if(Y0<Yc) y=Yc-tmpy;else y=Yc+tmpy;
		rep(i,-sz,sz) rep(j,-sz,sz) work(i,j);
		
		if(X0<Xc) x=Xc-tmpx;else x=Xc+tmpx;
		if(Y0<Yc) y=Yc+tmpy;else y=Yc-tmpy;
		rep(i,-sz,sz) rep(j,-sz,sz) work(i,j);
		
		if(X0<Xc) x=Xc+tmpx;else x=Xc-tmpx;
		if(Y0<Yc) y=Yc+tmpy;else y=Yc-tmpy;
		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: 1972ms
memory: 3604kb

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: 3596kb

input:

1
0 0 1 0 0

output:

0
0 0

result:

ok correct (1 test case)

Test #3:

score: -100
Time Limit Exceeded

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:


result: