QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#166537#7184. Transport Plusesucup-team1325#WA 1ms3956kbC++172.0kb2023-09-06 14:27:082023-09-06 14:27:09

Judging History

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

  • [2023-09-06 14:27:09]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3956kb
  • [2023-09-06 14:27:08]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

typedef long long ll; typedef unsigned long long ull;
const int inf = 1e9; const ll llnf = 4e18;

template< class Tp > void chkmax( Tp &x , Tp y ) { x = max( x , y ); }
template< class Tp > void chkmin( Tp &x , Tp y ) { x = min( x , y ); }

void solve( ) {
	int n , a , sx , sy , tx , ty; cin >> n >> a >> sx >> sy >> tx >> ty;
	vector< int > x( n + 1 ) , y( n + 1 ); for( int i = 1; i <= n; i ++ ) cin >> x[i] >> y[i];

	auto dist = [&] ( int x1 , int y1 , int x2 , int y2 ) -> long double { return sqrt( ( x1 - x2 ) * ( x1 - x2 ) + ( y1 - y2 ) * ( y1 - y2 ) ); } ;
	auto Dist = [&] ( int x1 , int y1 , int i ) -> long double { return min( abs( x1 - x[i] ) , abs( y1 - y[i] ) ); } ;

	long double ans = dist( sx , sy , tx , ty ); vector< int > pans = vector< int >{ };
	for( int i = 1; i <= n; i ++ ) {
		long double res = a + Dist( sx , sy , i ) + Dist( tx , ty , i );
		if( ans > res ) ans = res , pans = vector< int >{ i };
	}
	for( int i = 1; i <= n; i ++ ) for( int j = 1; j <= n; j ++ ) {
		long double res = 2 * a + Dist( sx , sy , i ) + Dist( tx , ty , j );
		if( ans > res ) ans = res , pans = vector< int >{ i , j };
	}

	cout << fixed << setprecision( 10 ) << ans << "\n";
	cout << ( int ) pans.size( ) + 1 << "\n";
	if( ( int ) pans.size( ) >= 1 ) {
		int i = pans[0];
		if( abs( sx - x[i] ) < abs( sy - y[i] ) ) cout << 0 << " " << x[i] << " " << sy << "\n";
		else cout << 0 << " " << sx << " " << y[i] << "\n";
	}
	if( ( int ) pans.size( ) >= 2 ) {
		cout << pans[0] << " " << x[pans[0]] << " " << y[pans[1]] << "\n";
	}
	if( ( int ) pans.size( ) >= 1 ) {
		int i = pans[( int ) pans.size( ) - 1];
		if( abs( tx - x[i] ) < abs( ty - y[i] ) ) cout << i << " " << x[i] << " " << ty << "\n";
		else cout << i << " " << tx << " " << y[i] << "\n";
	}
	cout << 0 << " " << tx << " " << ty << "\n";
}

int main( ) {
	ios::sync_with_stdio( 0 ), cin.tie( 0 ), cout.tie( 0 );
	int T = 1; while( T -- ) solve( ); return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 3956kb

input:

1 2
1 1
5 3
6 2

output:

4.0000000000
2
0 1 2
1 5 2
0 5 3

result:

wrong answer arrived at (5.000000, 2.000000) instead of (5.000000, 3.000000)