結果

問題 No.402 最も海から遠い場所
ユーザー akakimidoriakakimidori
提出日時 2016-12-12 03:16:58
言語 C90
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 914 bytes
コンパイル時間 281 ms
コンパイル使用メモリ 22,784 KB
実行使用メモリ 43,336 KB
最終ジャッジ日時 2024-05-07 01:52:38
合計ジャッジ時間 6,781 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 0 ms
13,880 KB
testcase_01 AC 1 ms
5,376 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 AC 1 ms
5,376 KB
testcase_04 AC 1 ms
5,376 KB
testcase_05 AC 0 ms
5,376 KB
testcase_06 AC 1 ms
5,376 KB
testcase_07 AC 0 ms
5,376 KB
testcase_08 AC 1 ms
5,376 KB
testcase_09 WA -
testcase_10 AC 1 ms
5,376 KB
testcase_11 AC 1 ms
5,376 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
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,1};
          int dy[]={-1, 1,-1,1};
          int l;
          for(l=0;l<4;l++){
            if(dp[POS(j+dx[l],k+dy[l])]<dp[POS(j,k)]){
              break;
            }
          }
          dp[POS(j,k)]+=(l==4?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