結果

問題 No.1413 Dynamic Sushi
ユーザー tailstails
提出日時 2021-03-03 18:12:49
言語 C
(gcc 12.3.0)
結果
WA  
実行時間 -
コード長 1,874 bytes
コンパイル時間 349 ms
コンパイル使用メモリ 34,528 KB
実行使用メモリ 6,824 KB
最終ジャッジ日時 2024-10-03 07:10:56
合計ジャッジ時間 2,099 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c: In function 'f':
main.c:7:16: warning: implicit declaration of function 'sincosf'; did you mean 'sincos'? [-Wimplicit-function-declaration]
    7 | #define sincos sincosf
      |                ^~~~~~~
main.c:32:17: note: in expansion of macro 'sincos'
   32 |                 sincos(ja,&sv,&cv);
      |                 ^~~~~~
main.c: At top level:
main.c:44:1: warning: return type defaults to 'int' [-Wimplicit-int]
   44 | main(){
      | ^~~~
main.c: In function 'main':
main.c:46:9: warning: implicit declaration of function 'scanf' [-Wimplicit-function-declaration]
   46 |         scanf("%d%d",&n,&w);
      |         ^~~~~
main.c:1:1: note: include '<stdio.h>' or provide a declaration of 'scanf'
  +++ |+#include <stdio.h>
    1 | #pragma GCC optimize("Ofast")
main.c:46:9: warning: incompatible implicit declaration of built-in function 'scanf' [-Wbuiltin-declaration-mismatch]
   46 |         scanf("%d%d",&n,&w);
      |         ^~~~~
main.c:46:9: note: include '<stdio.h>' or provide a declaration of 'scanf'
main.c:8:14: warning: implicit declaration of function 'sqrtf' [-Wimplicit-function-declaration]
    8 | #define sqrt sqrtf
      |              ^~~~~
main.c:62:27: note: in expansion of macro 'sqrt'
   62 |                 double hi=sqrt(sq(s[j].x)+sq(s[j].y))+s[j].r;
      |                           ^~~~
main.c:1:1: note: include '<math.h>' or provide a declaration of 'sqrtf'
  +++ |+#include <math.h>
    1 | #pragma GCC optimize("Ofast")
main.c:8:14: warning: incompatible implicit declaration of built-in function 'sqrtf' [-Wbuiltin-declaration-mismatch]
    8 | #define sqrt sqrtf
      |              ^~~~~
main.c:62:27: note: in expansion of macro 'sqrt'
   62 |                 double hi=sqrt(sq(s[j].x)+sq(s[j].y))+s[j].r;
      |                           ^~~~
main.c:8:14: note: include '<math.h>' or provide a declaration of 'sqrtf'
    8 | #define sqrt sqrtf
      |              ^~~~~
main.c:62:27: note: in expansion of macro 'sqrt'
   62 |         

ソースコード

diff #

#pragma GCC optimize("Ofast")
#pragma GCC target("avx2")

#define double float
#define cos cosf
#define sin sinf
#define sincos sincosf
#define sqrt sqrtf

#define PI (double)3.14159265358979323846

struct S {
	double x,y,r;
	double v,a;
} s[12];

double limit=2000;
double dp[1<<12][12];

static inline
double sq(double x){
	return x*x;
}

static inline
double f(double ix,double iy,double it,double lo,double hi,int j){
	for(int k=0;k<18;++k){
		double mid=(lo+hi)*.5f;
		double jt=it+mid;
		double ja=s[j].a+s[j].v*jt;
		double cv,sv;
		sincos(ja,&sv,&cv);
		double jx=s[j].x+s[j].r*cv;
		double jy=s[j].y+s[j].r*sv;
		if(sq(jx-ix)+sq(jy-iy)<sq(mid)){
			hi=mid;
		}else{
			lo=mid;
		}
	}
	return it+hi;
}

main(){
	int n,w;
	scanf("%d%d",&n,&w);
	for(int i=0;i<n;++i){
		int ix,iy,ir,iv,ia;
		scanf("%d%d%d%d%d",&ix,&iy,&ir,&iv,&ia);
		s[i].x=(double)ix/w;
		s[i].y=(double)iy/w;
		s[i].r=(double)ir/w;
		s[i].v=(double)iv*(PI/180);
		s[i].a=(double)ia*(PI/180);
	}
	for(int m=0;m<1<<n;++m){
		for(int j=0;j<n;++j){
			dp[m][j]=limit;
		}
	}
	for(int j=0;j<n;++j){
		double hi=sqrt(sq(s[j].x)+sq(s[j].y))+s[j].r;
		double lo=hi-s[j].r*2;
		if(lo<0){
			lo=0;
		}
		dp[1<<j][j]=f(0,0,0,lo,hi,j);
	}
	for(int m=0;m<1<<n;++m){
		for(int i=0;i<n;++i){
			if(m&1<<i){
				double it=dp[m][i];
				double ia=s[i].a+s[i].v*it;
				double cv,sv;
				sincos(ia,&sv,&cv);
				double ix=s[i].x+s[i].r*cv;
				double iy=s[i].y+s[i].r*sv;
				for(int j=0;j<n;++j){
					if(~m&1<<j){
						double hi=sqrt(sq(s[j].x-ix)+sq(s[j].y-iy))+s[j].r;
						double lo=hi-s[j].r*2;
						if(lo<0){
							lo=0;
						}
						if(dp[m|1<<j][j]>it+lo){
							double r=f(ix,iy,it,lo,hi,j);
							if(dp[m|1<<j][j]>r){
								dp[m|1<<j][j]=r;
							}
						}
					}
				}
			}
		}
	}
	double z=limit;
	for(int j=0;j<n;++j){
		double r=dp[(1<<n)-1][j];
		if(z>r){
			z=r;
		}
	}
	printf("%f",z);
}
0