結果

問題 No.707 書道
ユーザー kametarokametaro
提出日時 2018-07-02 19:26:33
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,756 bytes
コンパイル時間 730 ms
コンパイル使用メモリ 64,696 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-13 16:59:31
合計ジャッジ時間 1,609 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <cstdio>
#include <climits>
#include <algorithm>
#include <math.h>
using namespace std;
int main(){
    int h,w;
    cin>>h>>w;
    // scanf("%d",&h);
    // scanf("%d",&w);
    char paper[52][52]={};
    // string asas;
    // getline(&asas);
    getchar();
    // getchar();
    // getchar();
    for(int i=1;i<=h;i++){
        for(int j=1;j<=w;j++){
            //cin>>paper[j][i];
            paper[j][i]=getchar();
            // scanf("%c",paper[j][i]);
            // printf("-%c-",paper[j][i]);
        }
        getchar();
    }
    double tem,ans=9999999.9;

    for(int k=1;k<=w;k++){
        tem=0;
        for(int i=1;i<=h;i++){
            for(int j=1;j<=w;j++){
                if(paper[j][i]!='0'){
                    tem+=sqrt((k-j)*(k-j)+(i-0)*(i-0));
                }
            }
        }
        ans=min(ans,tem);
    }
    for(int k=1;k<=w;k++){
        tem=0;
        for(int i=1;i<=h;i++){
            for(int j=1;j<=w;j++){
                if(paper[j][i]!='0'){
                    tem+=sqrt((k-j)*(k-j)+(i-(h+1))*(i-(h+1)));
                }
            }
        }
        ans=min(ans,tem);
    }
    for(int k=0;k<=w;k++){
        tem=0;
        for(int i=1;i<=h;i++){
            for(int j=1;j<=w;j++){
                if(paper[j][i]!='0'){
                    tem+=sqrt((0-j)*(0-j)+(i-k)*(i-k));
                }
            }
        }
        ans=min(ans,tem);
    }
    for(int k=0;k<=w;k++){
        tem=0;
        for(int i=1;i<=h;i++){
            for(int j=1;j<=w;j++){
                if(paper[j][i]!='0'){
                    tem+=sqrt(((w+1)-j)*((w+1)-j)+(i-k)*(i-k));
                }
            }
        }
        ans=min(ans,tem);
    }

    cout<<ans<<endl;;
    return 0;
}
0