Submission #232088
Source Code Expand
#include <cmath>
#include <cstdio>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
const double EPS=1e-8;
struct point3{
double x,y,z;
point3():x(0),y(0),z(0){}
point3(double x,double y,double z):x(x),y(y),z(z){}
point3 operator-(const point3 &a)const{ return point3(x-a.x,y-a.y,z-a.z); }
};
double dot(const point3 &a,const point3 &b){ return a.x*b.x+a.y*b.y+a.z*b.z; }
point3 cross(const point3 &a,const point3 &b){ return point3(a.y*b.z-a.z*b.y,a.z*b.x-a.x*b.z,a.x*b.y-a.y*b.x); }
double abs(const point3 &a){ return sqrt(a.x*a.x+a.y*a.y+a.z*a.z); }
struct segment3{ point3 a,b; };
struct sphere{
point3 c;
double r;
sphere():c(point3(0,0,0)),r(0){}
};
double dist(const segment3 &S,const point3 &p){
if(dot(S.b-S.a,p-S.a)<=0) return abs(p-S.a);
if(dot(S.a-S.b,p-S.b)<=0) return abs(p-S.b);
return abs(cross(S.b-S.a,p-S.a))/abs(S.a-S.b);
}
bool intersect(const sphere &C,const segment3 &S){
return dist(S,C.c)<C.r+EPS;
}
int main(){
int n,q; scanf("%d%d",&n,&q);
sphere S[50];
ll cost[50];
rep(i,n) scanf("%lf%lf%lf%lf%lld",&S[i].c.x,&S[i].c.y,&S[i].c.z,&S[i].r,cost+i);
while(q--){
segment3 T;
scanf("%lf%lf%lf%lf%lf%lf",&T.a.x,&T.a.y,&T.a.z,&T.b.x,&T.b.y,&T.b.z);
ll ans=0;
rep(i,n) if(intersect(S[i],T)) ans+=cost[i];
printf("%lld\n",ans);
}
return 0;
}
Submission Info
Submission Time
2014-09-15 11:01:37+0900
Task
C - Magic Bullet
User
fura2
Language
C++ (GCC 4.4.7)
Score
100
Code Size
1396 Byte
Status
AC
Exec Time
30 ms
Memory
924 KB
Compile Error
./Main.cpp: In function ‘int main()’:
./Main.cpp:44: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result
./Main.cpp:47: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result
./Main.cpp:51: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result
Judge Result
Set Name
All
Score / Max Score
100 / 100
Status
Set Name
Test Cases
All
00_sample1, 00_sample2, 00_sample3, 10_random_00, 10_random_01, 10_random_02, 10_random_03, 10_random_04, 10_random_05, 10_random_06, 10_random_07, 10_random_08, 10_random_09, 10_random_10, 10_random_11, 10_random_12, 10_random_13, 10_random_14, 10_random_15, 10_random_16, 10_random_17, 10_random_18, 10_random_19, 10_random_20, 10_random_21, 10_random_22, 10_random_23, 10_random_24, 10_random_25, 10_random_26, 10_random_27, 10_random_28, 10_random_29, 10_random_30, 10_random_31, 10_random_32, 10_random_33, 10_random_34, 10_random_35, 10_random_36, 10_random_37, 10_random_38, 10_random_39, 10_random_40, 10_random_41, 10_random_42, 10_random_43, 10_random_44, 10_random_45, 10_random_46, 10_random_47, 10_random_48, 10_random_49, 90_man01, 90_man02, 90_man03
Case Name
Status
Exec Time
Memory
00_sample1
AC
23 ms
736 KB
00_sample2
AC
25 ms
792 KB
00_sample3
AC
23 ms
796 KB
10_random_00
AC
23 ms
800 KB
10_random_01
AC
24 ms
796 KB
10_random_02
AC
25 ms
668 KB
10_random_03
AC
22 ms
804 KB
10_random_04
AC
23 ms
664 KB
10_random_05
AC
24 ms
792 KB
10_random_06
AC
25 ms
740 KB
10_random_07
AC
23 ms
796 KB
10_random_08
AC
23 ms
796 KB
10_random_09
AC
22 ms
804 KB
10_random_10
AC
23 ms
744 KB
10_random_11
AC
21 ms
804 KB
10_random_12
AC
22 ms
800 KB
10_random_13
AC
23 ms
780 KB
10_random_14
AC
23 ms
744 KB
10_random_15
AC
23 ms
800 KB
10_random_16
AC
22 ms
792 KB
10_random_17
AC
22 ms
796 KB
10_random_18
AC
22 ms
700 KB
10_random_19
AC
23 ms
924 KB
10_random_20
AC
23 ms
784 KB
10_random_21
AC
23 ms
792 KB
10_random_22
AC
26 ms
676 KB
10_random_23
AC
23 ms
676 KB
10_random_24
AC
24 ms
800 KB
10_random_25
AC
24 ms
804 KB
10_random_26
AC
22 ms
676 KB
10_random_27
AC
22 ms
800 KB
10_random_28
AC
22 ms
672 KB
10_random_29
AC
23 ms
796 KB
10_random_30
AC
24 ms
800 KB
10_random_31
AC
24 ms
920 KB
10_random_32
AC
22 ms
668 KB
10_random_33
AC
23 ms
792 KB
10_random_34
AC
24 ms
796 KB
10_random_35
AC
26 ms
792 KB
10_random_36
AC
24 ms
696 KB
10_random_37
AC
21 ms
924 KB
10_random_38
AC
23 ms
796 KB
10_random_39
AC
24 ms
668 KB
10_random_40
AC
24 ms
788 KB
10_random_41
AC
24 ms
800 KB
10_random_42
AC
23 ms
676 KB
10_random_43
AC
21 ms
672 KB
10_random_44
AC
22 ms
800 KB
10_random_45
AC
24 ms
672 KB
10_random_46
AC
22 ms
796 KB
10_random_47
AC
30 ms
804 KB
10_random_48
AC
21 ms
672 KB
10_random_49
AC
22 ms
792 KB
90_man01
AC
22 ms
748 KB
90_man02
AC
23 ms
676 KB
90_man03
AC
25 ms
772 KB