結果

問題 No.707 書道
ユーザー phsplsphspls
提出日時 2020-04-28 20:59:09
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 3 ms / 2,000 ms
コード長 769 bytes
コンパイル時間 1,525 ms
コンパイル使用メモリ 169,456 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-16 18:11:18
合計ジャッジ時間 2,207 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 3 ms
4,376 KB
testcase_07 AC 3 ms
4,380 KB
testcase_08 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: 関数 ‘double calc(std::vector<std::__cxx11::basic_string<char> >, int, int, int, int)’ 内:
main.cpp:15:12: 警告: ‘ret’ may be used uninitialized [-Wmaybe-uninitialized]
   15 |     return ret;
      |            ^~~
main.cpp:7:12: 備考: ‘ret’ はここで定義されています
    7 |     double ret;
      |            ^~~

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define llong long long

double calc(vector<string> p, int h, int w, int i, int j) {
    double ret;
    rep(a, h) {
        rep(b, w) {
            if(p[a][b] == '1') {
                ret += sqrt((a-i)*(a-i) + (b-j)*(b-j));
            }
        }
    }
    return ret;
}

int main() {
    int h, w;
    cin >> h >> w;
    vector<string> p(h);
    rep(i, h) cin >> p[i];

    double result = 1.0 * INT_MAX;
    rep(i, w) result = min(result, calc(p, h, w, -1, i));
    rep(i, w) result = min(result, calc(p, h, w, h, i));
    rep(i, w) result = min(result, calc(p, h, w, i, -1));
    rep(i, w) result = min(result, calc(p, h, w, i, w));
    printf("%.8f\n", result);
}
0