結果

問題 No.707 書道
ユーザー ohreitetsuohreitetsu
提出日時 2018-06-30 22:23:49
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,044 bytes
コンパイル時間 693 ms
コンパイル使用メモリ 75,180 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-13 16:24:47
合計ジャッジ時間 1,335 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 WA -
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <stdio.h>
#include <string>
#include <vector>
#include <math.h>
using namespace std;
double GetDist(int x,int y,vector<pair<int,int>> &myV)
{
	int i;
	double dist=0;
	for (i=0;i<myV.size();i++){
		int x1=myV[i].first;
		int y1=myV[i].second;
		dist+=sqrt((double)(x-x1)*(x-x1)+(y-y1)*(y-y1));
	}
	return dist;
}
int main(int argc, char* argv[])
{
	int H,W;
	cin>>H>>W;
	vector<pair<int,int>> myV;
	int i,j;
	for (i=1;i<=H;i++){
		string S;
		cin>>S;
		for (j=0;j<S.size();j++){
			if (S[j]=='1'){
				myV.push_back(make_pair(i,j+1));
			}
		}
	}
	double dist;
	double MaxDist=1e9;
	i=0;
	for (j=1;j<=H;j++){
		dist=GetDist(i,j,myV);
		if (MaxDist>dist){
			MaxDist=dist;
		}
	}
	i=H+1;
	for (j=1;j<=H;j++){
		dist=GetDist(i,j,myV);
		if (MaxDist>dist){
			MaxDist=dist;
		}
	}
	
	j=0;
	for (i=1;i<=W;i++){
		dist=GetDist(i,j,myV);
		if (MaxDist>dist){
			MaxDist=dist;
		}
	}
	j=H+1;
	for (i=1;i<=W;i++){
		dist=GetDist(i,j,myV);
		if (MaxDist>dist){
			MaxDist=dist;
		}
	}
	printf("%.8lf\n",MaxDist);
	return 0;
}
0