結果
問題 | No.707 書道 |
ユーザー |
|
提出日時 | 2020-04-28 20:59:09 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 3 ms / 2,000 ms |
コード長 | 769 bytes |
コンパイル時間 | 1,534 ms |
コンパイル使用メモリ | 171,284 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-11-25 07:40:03 |
合計ジャッジ時間 | 2,097 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 6 |
コンパイルメッセージ
main.cpp: In function 'double calc(std::vector<std::__cxx11::basic_string<char> >, int, int, int, int)': main.cpp:15:12: warning: 'ret' may be used uninitialized [-Wmaybe-uninitialized] 15 | return ret; | ^~~ main.cpp:7:12: note: 'ret' was declared here 7 | double ret; | ^~~
ソースコード
#include <bits/stdc++.h>using namespace std;#define rep(i, n) for (int i = 0; i < (int)(n); i++)#define llong long longdouble 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);}