結果

問題 No.402 最も海から遠い場所
ユーザー akakimidoriakakimidori
提出日時 2016-12-12 03:09:33
言語 C90
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 934 bytes
コンパイル時間 1,002 ms
コンパイル使用メモリ 22,400 KB
実行使用メモリ 41,984 KB
最終ジャッジ日時 2024-05-07 01:50:53
合計ジャッジ時間 7,430 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 0 ms
10,752 KB
testcase_01 AC 1 ms
5,376 KB
testcase_02 AC 0 ms
5,376 KB
testcase_03 AC 0 ms
5,376 KB
testcase_04 AC 0 ms
5,376 KB
testcase_05 AC 1 ms
5,376 KB
testcase_06 AC 0 ms
5,376 KB
testcase_07 AC 0 ms
5,376 KB
testcase_08 AC 1 ms
5,376 KB
testcase_09 AC 1 ms
5,376 KB
testcase_10 AC 0 ms
5,376 KB
testcase_11 AC 1 ms
5,376 KB
testcase_12 AC 0 ms
5,376 KB
testcase_13 AC 2 ms
5,376 KB
testcase_14 AC 2 ms
5,376 KB
testcase_15 AC 18 ms
5,376 KB
testcase_16 AC 31 ms
5,376 KB
testcase_17 AC 1,110 ms
18,560 KB
testcase_18 TLE -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c: In function ‘run’:
main.c:8:3: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    8 |   scanf("%d%d",&h,&w);
      |   ^~~~~~~~~~~~~~~~~~~
main.c:14:5: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   14 |     scanf("%s",s);
      |     ^~~~~~~~~~~~~

ソースコード

diff #

#include<stdio.h>
#include<stdlib.h>

#define POS(i,j) ((i)*w+(j))

void run(void){
  int h,w;
  scanf("%d%d",&h,&w);

  int *dp=(int *)malloc(sizeof(int)*h*w);
  int i;
  for(i=0;i<h;i++){
    char s[3001];
    scanf("%s",s);
    int j;
    for(j=0;j<w;j++){
      dp[POS(i,j)]=(s[j]=='#'?1:0);
    }
  }

  for(i=1;i<h/2 && i<w/2;i++){
    int j;
    for(j=i;j<h-i;j++){
      int k;
      for(k=i;k<w-i;k++){
        if(dp[POS(j,k)]==i){
          int dx[]={-1,-1,-1, 0,0, 1,1,1};
          int dy[]={-1, 0, 1,-1,1,-1,0,1};
          int l;
          for(l=0;l<8;l++){
            if(dp[POS(j+dx[l],k+dy[l])]<dp[POS(j,k)]){
              break;
            }
          }
          dp[POS(j,k)]+=(l==8?1:0);
        }
      }
    }
  }

  int max=0;
  for(i=0;i<h;i++){
    int j;
    for(j=0;j<w;j++){
      max=max<dp[POS(i,j)]?dp[POS(i,j)]:max;
    }
  }
  printf("%d\n",max);
  return;
}

int main(void){
  run();
  return 0;
}
0