結果

問題 No.707 書道
ユーザー 🍮かんプリン🍮かんプリン
提出日時 2019-03-07 10:09:23
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 3 ms / 2,000 ms
コード長 964 bytes
コンパイル時間 1,606 ms
コンパイル使用メモリ 70,800 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-05 19:20:20
合計ジャッジ時間 1,853 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#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;
}
0