結果
| 問題 | No.707 書道 | 
| コンテスト | |
| ユーザー |  🍮かんプリン | 
| 提出日時 | 2019-03-07 10:09:23 | 
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 3 ms / 2,000 ms | 
| コード長 | 964 bytes | 
| コンパイル時間 | 717 ms | 
| コンパイル使用メモリ | 70,720 KB | 
| 実行使用メモリ | 6,944 KB | 
| 最終ジャッジ日時 | 2024-06-23 14:45:47 | 
| 合計ジャッジ時間 | 1,247 ms | 
| ジャッジサーバーID (参考情報) | judge5 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 6 | 
ソースコード
#include <iostream>
#include <vector>
#include <math.h>
#include <algorithm>
using namespace std;
int main(){
    int H,W;
    double d,a = 177500;
    cin >> H >> W;
    vector< vector<char> > P(H, vector<char>(W));
    for(int i = 0; i < H; i++)
    {
        for(int j = 0; j < W; j++)
        {
            cin >> P[i][j];
        }
    }
    for(int i = 0; i <= H + 1; i++)
    {
        for(int j = 0; j <= W + 1; j++)
        {
            if ((i == 0) ^ (j == 0) ^ (i == H + 1) ^ (j == W + 1)) {
                d = 0;
                for(int x = 0; x < H; x++)
                {
                    for(int y = 0; y < W; y++)
                    {
                        if (P[x][y] == '1') {
                            d += sqrt((x + 1 - i) * (x + 1 - i) + (y + 1 - j) * (y + 1 - j));
                        }
                    }
                }
                a = min(a,d);
            }
        }
    }
    printf("%.8f\n", a);
    return 0;
}
            
            
            
        