結果
問題 | No.1413 Dynamic Sushi |
ユーザー | tails |
提出日時 | 2021-03-03 17:04:20 |
言語 | C (gcc 12.3.0) |
結果 |
AC
|
実行時間 | 129 ms / 4,000 ms |
コード長 | 1,413 bytes |
コンパイル時間 | 1,284 ms |
コンパイル使用メモリ | 33,876 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-10-03 06:11:47 |
合計ジャッジ時間 | 3,953 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
6,820 KB |
testcase_01 | AC | 120 ms
6,820 KB |
testcase_02 | AC | 1 ms
6,816 KB |
testcase_03 | AC | 1 ms
6,820 KB |
testcase_04 | AC | 116 ms
6,816 KB |
testcase_05 | AC | 109 ms
6,816 KB |
testcase_06 | AC | 117 ms
6,820 KB |
testcase_07 | AC | 123 ms
6,816 KB |
testcase_08 | AC | 113 ms
6,820 KB |
testcase_09 | AC | 109 ms
6,816 KB |
testcase_10 | AC | 114 ms
6,816 KB |
testcase_11 | AC | 120 ms
6,816 KB |
testcase_12 | AC | 118 ms
6,816 KB |
testcase_13 | AC | 125 ms
6,816 KB |
testcase_14 | AC | 118 ms
6,816 KB |
testcase_15 | AC | 118 ms
6,816 KB |
testcase_16 | AC | 112 ms
6,820 KB |
testcase_17 | AC | 128 ms
6,816 KB |
testcase_18 | AC | 129 ms
6,820 KB |
testcase_19 | AC | 117 ms
6,820 KB |
testcase_20 | AC | 52 ms
6,816 KB |
testcase_21 | AC | 2 ms
6,816 KB |
testcase_22 | AC | 119 ms
6,816 KB |
testcase_23 | AC | 114 ms
6,820 KB |
testcase_24 | AC | 121 ms
6,820 KB |
コンパイルメッセージ
main.c: In function 'f': main.c:24:20: warning: implicit declaration of function 'sqrt' [-Wimplicit-function-declaration] 24 | double hi=(sqrt(sq(s[j].x-ix)+sq(s[j].y-iy))+s[j].r)/w; | ^~~~ main.c:1:1: note: include '<math.h>' or provide a declaration of 'sqrt' +++ |+#include <math.h> 1 | #pragma GCC optimize("Ofast") main.c:24:20: warning: incompatible implicit declaration of built-in function 'sqrt' [-Wbuiltin-declaration-mismatch] 24 | double hi=(sqrt(sq(s[j].x-ix)+sq(s[j].y-iy))+s[j].r)/w; | ^~~~ main.c:24:20: note: include '<math.h>' or provide a declaration of 'sqrt' main.c:29:41: warning: implicit declaration of function 'cos' [-Wimplicit-function-declaration] 29 | double jx=s[j].x+s[j].r*cos(ja); | ^~~ main.c:29:41: note: include '<math.h>' or provide a declaration of 'cos' main.c:29:41: warning: incompatible implicit declaration of built-in function 'cos' [-Wbuiltin-declaration-mismatch] main.c:29:41: note: include '<math.h>' or provide a declaration of 'cos' main.c:30:41: warning: implicit declaration of function 'sin' [-Wimplicit-function-declaration] 30 | double jy=s[j].y+s[j].r*sin(ja); | ^~~ main.c:30:41: note: include '<math.h>' or provide a declaration of 'sin' main.c:30:41: warning: incompatible implicit declaration of built-in function 'sin' [-Wbuiltin-declaration-mismatch] main.c:30:41: note: include '<math.h>' or provide a declaration of 'sin' main.c: At top level: main.c:40:1: warning: return type defaults to 'int' [-Wimplicit-int] 40 | main(){ | ^~~~ main.c: In function 'main': main.c:41:9: warning: implicit declaration of function 'scanf' [-Wimplicit-function-declaration] 41 | scanf("%d%lf",&n,&w); | ^~~~~ main.c:1:1: note: include '<stdio.h>' or provide a declaration of 'scanf' +++ |+#include <stdio.h>
ソースコード
#pragma GCC optimize("Ofast") #pragma GCC target("avx2") #define PI 3.14159265358979323846 struct S { int x,y,r; double v,a; } s[12]; int n; double w; 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,int j){ double lo=0; double hi=(sqrt(sq(s[j].x-ix)+sq(s[j].y-iy))+s[j].r)/w; for(int k=0;k<18;++k){ double mid=(lo+hi)*.5; 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*w)){ hi=mid; }else{ lo=mid; } } return it+hi; } main(){ scanf("%d%lf",&n,&w); for(int i=0;i<n;++i){ scanf("%d%d%d%lf%lf",&s[i].x,&s[i].y,&s[i].r,&s[i].v,&s[i].a); s[i].v*=PI/180; s[i].a*=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){ dp[1<<j][j]=f(0,0,0,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&&dp[m|1<<j][j]>it){ double r=f(ix,iy,it,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); }