結果

問題 No.1413 Dynamic Sushi
ユーザー tailstails
提出日時 2021-03-03 17:46:37
言語 C
(gcc 12.3.0)
結果
AC  
実行時間 99 ms / 4,000 ms
コード長 1,791 bytes
コンパイル時間 845 ms
コンパイル使用メモリ 35,600 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-14 09:50:39
合計ジャッジ時間 2,766 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,812 KB
testcase_01 AC 99 ms
6,940 KB
testcase_02 AC 1 ms
6,940 KB
testcase_03 AC 1 ms
6,944 KB
testcase_04 AC 61 ms
6,940 KB
testcase_05 AC 80 ms
6,944 KB
testcase_06 AC 61 ms
6,944 KB
testcase_07 AC 62 ms
6,940 KB
testcase_08 AC 72 ms
6,940 KB
testcase_09 AC 69 ms
6,940 KB
testcase_10 AC 76 ms
6,944 KB
testcase_11 AC 70 ms
6,940 KB
testcase_12 AC 70 ms
6,944 KB
testcase_13 AC 62 ms
6,944 KB
testcase_14 AC 55 ms
6,940 KB
testcase_15 AC 61 ms
6,944 KB
testcase_16 AC 67 ms
6,944 KB
testcase_17 AC 47 ms
6,940 KB
testcase_18 AC 55 ms
6,940 KB
testcase_19 AC 56 ms
6,940 KB
testcase_20 AC 26 ms
6,944 KB
testcase_21 AC 1 ms
6,944 KB
testcase_22 AC 88 ms
6,940 KB
testcase_23 AC 74 ms
6,940 KB
testcase_24 AC 76 ms
6,940 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c: In function 'f':
main.c:5:13: warning: implicit declaration of function 'cosf' [-Wimplicit-function-declaration]
    5 | #define cos cosf
      |             ^~~~
main.c:30:41: note: in expansion of macro 'cos'
   30 |                 double jx=s[j].x+s[j].r*cos(ja);
      |                                         ^~~
main.c:1:1: note: include '<math.h>' or provide a declaration of 'cosf'
  +++ |+#include <math.h>
    1 | #pragma GCC optimize("Ofast")
main.c:5:13: warning: incompatible implicit declaration of built-in function 'cosf' [-Wbuiltin-declaration-mismatch]
    5 | #define cos cosf
      |             ^~~~
main.c:30:41: note: in expansion of macro 'cos'
   30 |                 double jx=s[j].x+s[j].r*cos(ja);
      |                                         ^~~
main.c:5:13: note: include '<math.h>' or provide a declaration of 'cosf'
    5 | #define cos cosf
      |             ^~~~
main.c:30:41: note: in expansion of macro 'cos'
   30 |                 double jx=s[j].x+s[j].r*cos(ja);
      |                                         ^~~
main.c:6:13: warning: implicit declaration of function 'sinf' [-Wimplicit-function-declaration]
    6 | #define sin sinf
      |             ^~~~
main.c:31:41: note: in expansion of macro 'sin'
   31 |                 double jy=s[j].y+s[j].r*sin(ja);
      |                                         ^~~
main.c:6:13: note: include '<math.h>' or provide a declaration of 'sinf'
    6 | #define sin sinf
      |             ^~~~
main.c:31:41: note: in expansion of macro 'sin'
   31 |                 double jy=s[j].y+s[j].r*sin(ja);
      |                                         ^~~
main.c:6:13: warning: incompatible implicit declaration of built-in function 'sinf' [-Wbuiltin-declaration-mismatch]
    6 | #define sin sinf
      |             ^~~~
main.c:31:41: note: in expansion of macro 'sin'
   31 |                 double jy=s[j].y+s[j].r*sin(ja);
      |                                         ^~~
main.c:6:13: note: includ

ソースコード

diff #

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

#define double float
#define cos cosf
#define sin sinf
#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 jx=s[j].x+s[j].r*cos(ja);
		double jy=s[j].y+s[j].r*sin(ja);
		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 ix=s[i].x+s[i].r*cos(ia);
				double iy=s[i].y+s[i].r*sin(ia);
				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