本地运行答案正确但交上去只有20pts
查看原帖
本地运行答案正确但交上去只有20pts
606080
Dr_Einzbern楼主2023/10/4 20:35

(标题抄的楼上,勿喷(((

数据:

1
3 10 1 3
2 2 2 1 1 2 10
2 12 12 2 22 12 1
22 22 22 32 32 22 10

本地(VSCode和DevC++)和洛谷IDE跑出来均为214.1;而提交记录显示输出为0(是的,IDE也没问题qwq)

代码:

#include<bits/stdc++.h>
using namespace std;
const int N = 555;
double esp = 1e-8;
int S, t, A, B;
struct city{
	int x[6];
	int y[6];
} c[N];
double dis[N][N];
bool ds(double a, double b){
	return fabs(a-b) <= esp;
}
double len(int x1, int y1, int x2, int y2){
	return sqrt(1.0*(x1-x2)*(x1-x2) + 1.0*(y1-y2)*(y1-y2));
}
bool check(double a, double b, double c){//c为锟斤拷 
	return ds(a*a + b*b, c*c);
}
int rex(int a, int b, int c){//c为锟斤拷锟斤拷 
	return a + b - c;
}
int main(){
	int x1, x2, x3, x4, y1, y2, y3, y4, w;
	double l12, l13, l14, l23, l24, l34;
	int T;
	cin >> T;
	while(T--){
		scanf("%d%d%d%d", &S, &t, &A, &B);
		memset(dis, 0x3f, sizeof(dis));
		for(int i = 1; i <= N; i++){
			memset(c[i].x, 0, sizeof(c[i].x));
			memset(c[i].y, 0, sizeof(c[i].y));
		}
		int n = (S<<2);
		for(int i = 1; i <= S; i++){
			int j = (i<<2);
			scanf("%d%d%d%d%d%d%d", &x1, &y1, &x2, &y2, &x3, &y3, &w);
			l12 = len(x1, y1, x2, y2);
			l23 = len(x2, y2, x3, y3);
			l13 = len(x1, y1, x3, y3);
			if(check(l12, l23, l13)){
				x4 = rex(x3, x1, x2);
				y4 = rex(y3, y1, y2);
			}
			else if(check(l12, l13, l23)){
				x4 = rex(x3, x2, x1);
				y4 = rex(y3, y2, y1);
			}
			else{
				x4 = rex(x2, x1, x3);
				y4 = rex(y2, y1, y3);
			}
			c[i].x[1] = x1, c[i].x[2] = x2, c[i].x[3] = x3, c[i].x[4] = x4;
			c[i].y[1] = y1, c[i].y[2] = y2, c[i].y[3] = y3, c[i].y[4] = y4;
			l14 = len(x1, y1, x4, y4);
			l24 = len(x2, y2, x4, y4);
			l34 = len(x3, y3, x4, y4);
			dis[j+1][j+2] = l12*(1.0*w); dis[j+2][j+1] = l12*(1.0*w);
			dis[j+1][j+3] = l13*(1.0*w); dis[j+3][j+1] = l13*(1.0*w);
			dis[j+1][j+4] = l14*(1.0*w); dis[j+4][j+1] = l14*(1.0*w);
			dis[j+2][j+3] = l23*(1.0*w); dis[j+3][j+2] = l23*(1.0*w);
			dis[j+2][j+4] = l24*(1.0*w); dis[j+4][j+2] = l24*(1.0*w);
			dis[j+3][j+4] = l34*(1.0*w); dis[j+4][j+3] = l34*(1.0*w);
		}
		for(int i = 1; i <= S; i++){
			for(int j = i+1; j <= S; j++){
				int ii = (i<<2);
				int jj = (j<<2);
				for(int k1 = 1; k1 <= 4; k1++){
					for(int k2 = 1; k2 <= 4; k2++){
						dis[ii+k1][jj+k2] = len(c[i].x[k1], c[i].y[k1], c[j].x[k2], c[j].y[k2])*(1.0*t);
						dis[jj+k2][ii+k1] = len(c[i].x[k1], c[i].y[k1], c[j].x[k2], c[j].y[k2])*(1.0*t);
					}
				}
			}
		}
		for(int k = 1+4; k <= n+4; k++){
			for(int i = 1+4; i <= n+4; i++){
				for(int j = 1+4; j <= n+4; j++){
					dis[i][j] = min(dis[i][j], dis[i][k] + dis[k][j]);
				}
			}
		}
		double ans = 998114514;
		int AA = (A<<2);
		int BB = (B<<2);
		for(int k1 = 1; k1 <= 4; k1++){
			for(int k2 = 1; k2 <= 4; k2++){
				ans = min(ans, dis[AA+k1][BB+k2]);
			}
		}
		printf("%.1lf", ans);
	} 
	return 0;
}

2023/10/4 20:35
加载中...