結果
| 問題 |
No.707 書道
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2018-06-30 22:23:49 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,044 bytes |
| コンパイル時間 | 651 ms |
| コンパイル使用メモリ | 75,812 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-07-01 01:01:33 |
| 合計ジャッジ時間 | 1,125 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 4 WA * 2 |
ソースコード
#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;
}