結果
問題 | No.707 書道 |
ユーザー | donkorin_ |
提出日時 | 2018-07-09 10:39:56 |
言語 | C++11 (gcc 11.4.0) |
結果 |
AC
|
実行時間 | 4 ms / 2,000 ms |
コード長 | 1,406 bytes |
コンパイル時間 | 1,279 ms |
コンパイル使用メモリ | 146,476 KB |
実行使用メモリ | 4,380 KB |
最終ジャッジ日時 | 2023-09-22 08:33:17 |
合計ジャッジ時間 | 2,081 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge12 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
4,380 KB |
testcase_01 | AC | 1 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 | 3 ms
4,376 KB |
testcase_06 | AC | 3 ms
4,380 KB |
testcase_07 | AC | 4 ms
4,380 KB |
testcase_08 | AC | 2 ms
4,376 KB |
ソースコード
#include <bits/stdc++.h> #define rep(i,a,b) for(int i=a;i<(b);++i) #define erep(i,a,b) for(int i=a;i<=(int)(b);++i) #define per(i,a,b) for(int i=(b);i>(a);--i) #define eper(i,a,b) for(int i=((int)(a));i>=b;--i) #define pb push_back #define mp make_pair #define INF 1e18 #define MOD 1000000007 using namespace std; typedef long long ll; typedef pair<int,int> P; int dy[]={0, 0, 1, -1}; int dx[]={1, -1, 0, 0}; int gcd(int a,int b){return b?gcd(b,a%b):a;} int lcm(int a,int b){return a/gcd(a, b)*b;} string s[51]; int h, w, p[52][52]; double ans = DBL_MAX; int main() { ios::sync_with_stdio ( false ); cin.tie ( 0 ); cin >> h >> w; erep(i, 1, h) cin >> s[i]; erep(i, 1, h) rep(j, 0, w) { int c = s[i][j] - '0'; p[i][j+1] = c; } erep(i, 0, h+1) { erep(j, 0, w+1) { if (i * j == 0 || i == h+1 || j == w+1) p[i][j] = -1; } } erep(i, 0, h+1) { erep(j, 0, w+1) { if (p[i][j] != -1) continue; else { double sum = 0.0; erep(k, 1, h) { erep(l, 1, w) { if (p[k][l] == 1) { sum += sqrt((i-k)*(i-k) + (j-l)*(j-l)); } } } ans = min(ans, sum); } } } printf("%.12f\n", ans); return 0; }