結果
問題 | No.707 書道 |
ユーザー | ldsyb |
提出日時 | 2018-06-29 22:41:39 |
言語 | C++14 (gcc 13.2.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 627 bytes |
コンパイル時間 | 1,593 ms |
コンパイル使用メモリ | 166,604 KB |
実行使用メモリ | 4,380 KB |
最終ジャッジ日時 | 2023-09-13 15:27:07 |
合計ジャッジ時間 | 2,208 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge11 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
4,376 KB |
testcase_01 | AC | 2 ms
4,376 KB |
testcase_02 | AC | 2 ms
4,380 KB |
testcase_03 | AC | 1 ms
4,380 KB |
testcase_04 | AC | 1 ms
4,380 KB |
testcase_05 | AC | 2 ms
4,380 KB |
testcase_06 | AC | 2 ms
4,376 KB |
testcase_07 | AC | 2 ms
4,376 KB |
testcase_08 | AC | 2 ms
4,380 KB |
ソースコード
#include <bits/stdc++.h> using namespace std; int main() { int64_t h, w; cin >> h >> w; string s[h]; for (auto &i : s) { cin >> i; } double ans = (1ll << 60); for (int i = 0; i <= h + 1; i++) { for (int j = 0; j <= w + 1; j++) { if (i != 0 && i != h + 1 && j != 0 && j != w + 1) { continue; } double tmp = 0; for (int k = 1; k <= h; k++) { for (int l = 1; l <= w; l++) { if (s[k - 1][l - 1] == '1') { tmp += sqrt((i - k) * (i - k) + (j - l) * (j - l)); } } } ans = min(ans, tmp); } } cout << fixed << setprecision(20) << ans << endl; return 0; }