QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#73309#4390. KeychainspoiCompile Error//C++3.8kb2023-01-23 17:49:412023-01-23 17:49:44

Judging History

你现在查看的是最新测评结果

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-01-23 17:49:44]
  • 评测
  • [2023-01-23 17:49:41]
  • 提交

answer

#include "iostream"
#include "cstring"
#include "cstdio"
#include "algorithm"
#include "queue"
#include "vector"
#include "queue"
#include "stack"
#include "ctime"
#include "set"
#include "map"
#include "cmath"
using namespace std;
#define fi first
#define se second
#define vi vector<int>
#define pb push_back
#define eb emplace_back
#define pii pair<int,int>
#define mp make_pair
#define rep( i , a , b ) for( int i = (a) , i##end = b ; i <= i##end ; ++ i )
#define per( i , a , b ) for( int i = (a) , i##end = b ; i >= i##end ; -- i )
#define mem( a ) memset( a , 0 , sizeof (a) )
#define all( x ) x.begin() , x.end()
//#define int long long
typedef long long ll;
const int MAXN = 2e5 + 10;
const double eps = 1e-7;
int n , m;

double hypot( double x , double y , double z ) {
	return sqrt( x * x + y * y + z * z );
}

struct poi {
	double x , y , z;
	void in( ) {
		int x1 , y1 , z1;
		scanf("%d%d%d",&x1,&y1,&z1);
		x = x1 , y = y1 , z = z1;
	}
	poi( ) {}
	poi( double x , double y , double z ) : x(x) , y(y) , z(z) {}
	poi operator + ( const poi& b ) {
		return poi( x + b.x , y + b.y , z + b.z );
	}
	poi operator - ( const poi& b ) {
		return poi( x - b.x , y - b.y , z - b.z );
	}
	poi operator * ( const double& b ) {
		return poi( b * x , b * y , b * z );
	}
	poi operator / ( const double& b ) {
		return poi( x / b , y / b , z / b );
	}
	poi ori( ) {
		return ( *this ) / hypot( x , y , z );
	}
	double dis( ) {
		return hypot( x , y , z );
	}
} O1 , O2 , V1 , V2 , C1 , C2;
double r1 , r2;

poi det( const poi& a , const poi& b ) {
	return poi( 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 dot( const poi& a , const poi& b ) {
	return a.x * b.x + a.y * b.y + a.z * b.z;
}

double det( double a , double b , double c , double d ) {
	return a * d - b * c;
}
pair<double,double> solve( double a1 , double b1 , double c1 , double a2 , double b2 , double c2 ) {
	return mp( det( c1 , b1 , c2 , b2 ) / det( a1 , b1 , a2 , b2 ) , det( a1 , c1 , a2 , c2 ) / det( a1 , b1 , a2 , b2 ) );
}


void solve() {
	int t;
	O1.in() , V1.in() , scanf("%d",&t);
	r1 = t;
	O2.in() , V2.in() , scanf("%d",&t);
	r2 = t;
	
	if( fabs( det( V1 , V2 ).dis() ) < eps ) {
		puts("No");
		return;
	}
	if( fabs( det( V1.x , V1.z , V2.x , V2.z ) ) > eps ) {
		C1.y = 0.5;
		auto re = solve( V1.x , V1.z , dot( V1 , O1 ) - V1.y * C1.y , V2.x , V2.z , dot( V2 , O2 ) - V2.y * C1.y );
		C1.x = re.fi , C1.z = re.se;
		
		
		C2.y = -0.5;
		re = solve( V1.x , V1.z , dot( V1 , O1 ) - V1.y * C2.y , V2.x , V2.z , dot( V2 , O2 ) - V2.y * C2.y );
		C2.x = re.fi , C2.z = re.se;
	} else if( fabs( det( V1.y , V1.z , V2.y , V2.z ) ) > eps ) {
		C1.x = 0.5;
		auto re = solve( V1.y , V1.z , dot( V1 , O1 ) - V1.x * C1.x , V2.y , V2.z , dot( V2 , O2 ) - V2.x * C1.x );
		C1.y = re.fi , C1.z = re.se;
		
		
		C2.x = -0.5;
		re = solve( V1.y , V1.z , dot( V1 , O1 ) - V1.x * C2.x , V2.y , V2.z , dot( V2 , O2 ) - V2.x * C2.x );
		C2.y = re.fi , C2.z = re.se;
	} else {
		C1.z = 0.5;
		auto re = solve( V1.x , V1.y , dot( V1 , O1 ) - V1.z * C1.z , V2.x , V2.y , dot( V2 , O2 ) - V2.z * C1.z );
		C1.x = re.fi , C1.y = re.se;
		
		
		C2.z = -0.5;
		re = solve( V1.x , V1.y , dot( V1 , O1 ) - V1.z * C2.z , V2.x , V2.y , dot( V2 , O2 ) - V2.z * C2.z );
		C2.x = re.fi , C2.y = re.se;
		
	}
	
	
	poi L = C2 - C1;
	poi F = det( L , V2 ) , tp = C2 - O2;
	poi S = F.ori() * ( dot( F , tp ) / hypot( F.x , F.y , F.z ) );
	double d = sqrt( r2 * r2 - S.dis( ) * S.dis() );
	
	poi P = O2 + S;
	poi P1 = P + L.ori() * d , P2 = P - L.ori() * d;
	
	if( ( ( P1 - O1 ).dis() < r1 ) ^ ( ( P2 - O1 ).dis() < r1 ) ) puts("Yes");
	else puts("No");
}

signed main() {
//	freopen("in","r",stdin);
//	freopen("out","w",stdout);
	int T;cin >> T;while( T-- ) solve();
//	solve();
}

详细

answer.code: In member function ‘poi poi::ori()’:
answer.code:57:41: error: call of overloaded ‘hypot(double&, double&, double&)’ is ambiguous
   57 |                 return ( *this ) / hypot( x , y , z );
      |                                    ~~~~~^~~~~~~~~~~~~
answer.code:31:8: note: candidate: ‘double hypot(double, double, double)’
   31 | double hypot( double x , double y , double z ) {
      |        ^~~~~
In file included from answer.code:12:
/usr/include/c++/11/cmath:1876:3: note: candidate: ‘long double std::hypot(long double, long double, long double)’
 1876 |   hypot(long double __x, long double __y, long double __z)
      |   ^~~~~
/usr/include/c++/11/cmath:1872:3: note: candidate: ‘double std::hypot(double, double, double)’
 1872 |   hypot(double __x, double __y, double __z)
      |   ^~~~~
/usr/include/c++/11/cmath:1868:3: note: candidate: ‘float std::hypot(float, float, float)’
 1868 |   hypot(float __x, float __y, float __z)
      |   ^~~~~
answer.code: In member function ‘double poi::dis()’:
answer.code:60:29: error: call of overloaded ‘hypot(double&, double&, double&)’ is ambiguous
   60 |                 return hypot( x , y , z );
      |                        ~~~~~^~~~~~~~~~~~~
answer.code:31:8: note: candidate: ‘double hypot(double, double, double)’
   31 | double hypot( double x , double y , double z ) {
      |        ^~~~~
In file included from answer.code:12:
/usr/include/c++/11/cmath:1876:3: note: candidate: ‘long double std::hypot(long double, long double, long double)’
 1876 |   hypot(long double __x, long double __y, long double __z)
      |   ^~~~~
/usr/include/c++/11/cmath:1872:3: note: candidate: ‘double std::hypot(double, double, double)’
 1872 |   hypot(double __x, double __y, double __z)
      |   ^~~~~
/usr/include/c++/11/cmath:1868:3: note: candidate: ‘float std::hypot(float, float, float)’
 1868 |   hypot(float __x, float __y, float __z)
      |   ^~~~~
answer.code: In function ‘void solve()’:
answer.code:124:50: error: call of overloaded ‘hypot(double&, double&, double&)’ is ambiguous
  124 |         poi S = F.ori() * ( dot( F , tp ) / hypot( F.x , F.y , F.z ) );
      |                                             ~~~~~^~~~~~~~~~~~~~~~~~~
answer.code:31:8: note: candidate: ‘double hypot(double, double, double)’
   31 | double hypot( double x , double y , double z ) {
      |        ^~~~~
In file included from answer.code:12:
/usr/include/c++/11/cmath:1876:3: note: candidate: ‘long double std::hypot(long double, long double, long double)’
 1876 |   hypot(long double __x, long double __y, long double __z)
      |   ^~~~~
/usr/include/c++/11/cmath:1872:3: note: candidate: ‘double std::hypot(double, double, double)’
 1872 |   hypot(double __x, double __y, double __z)
      |   ^~~~~
/usr/include/c++/11/cmath:1868:3: note: candidate: ‘float std::hypot(float, float, float)’
 1868 |   hypot(float __x, float __y, float __z)
      |   ^~~~~
answer.code:82:34: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   82 |         O1.in() , V1.in() , scanf("%d",&t);
      |                             ~~~~~^~~~~~~~~
answer.code:84:34: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   84 |         O2.in() , V2.in() , scanf("%d",&t);
      |                             ~~~~~^~~~~~~~~
answer.code: In member function ‘void poi::in()’:
answer.code:39:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   39 |                 scanf("%d%d%d",&x1,&y1,&z1);
      |                 ~~~~~^~~~~~~~~~~~~~~~~~~~~~