結果
問題 | No.707 書道 |
ユーザー |
![]() |
提出日時 | 2019-06-25 18:45:02 |
言語 | C (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 5 ms / 2,000 ms |
コード長 | 1,008 bytes |
コンパイル時間 | 471 ms |
コンパイル使用メモリ | 31,616 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-06-23 04:44:52 |
合計ジャッジ時間 | 1,031 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 6 |
コンパイルメッセージ
main.c: In function 'in': main.c:8:14: warning: implicit declaration of function 'getchar_unlocked' [-Wimplicit-function-declaration] 8 | #define gc() getchar_unlocked() | ^~~~~~~~~~~~~~~~ main.c:14:24: note: in expansion of macro 'gc' 14 | int n = 0, c = gc(); | ^~
ソースコード
// yukicoder: No.707 書道 // 2019.6.25 bal4u #include <stdio.h> #include <math.h> #if 1 #define gc() getchar_unlocked() #else #define gc() getchar() #endif int in() { // 非負整数の入力 int n = 0, c = gc(); do n = 10 * n + (c & 0xf); while ((c = gc()) >= '0'); return n; } void ins(char *s) // 文字列の入力 スペース以下の文字で入力終了 { int c; while (1) { if ((c = gc()) < '0') break; *s++ = c & 1; } } int H, W; char map[55][55]; double ans; void calc(int r0, int c0) { int r, c; double s = 0; for (r = 1; r <= H; r++) for (c = 1; c <= W; c++) if (map[r][c]) { s += hypot(r-r0, c-c0); if (s > ans) return; } ans = s; } int main() { int r, c; H = in(), W = in(); for (r = 1; r <= H; r++) ins(map[r]+1); ans = 1.0e20; r = 0; for (c = 1; c <= W; c++) calc(r, c); r = H+1; for (c = 1; c <= W; c++) calc(r, c); c = 0; for (r = 1; r <= H; r++) calc(r, c); c = W+1; for (r = 1; r <= H; r++) calc(r, c); printf("%.12lf\n", ans); return 0; }