結果

問題 No.179 塗り分け
ユーザー tyabu
提出日時 2016-07-26 16:45:21
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 621 bytes
コンパイル時間 145 ms
コンパイル使用メモリ 23,296 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-10-03 03:26:29
合計ジャッジ時間 1,276 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample WA * 6
other WA * 40
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:12:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   12 |   scanf("%d %d", &h, &w);
      |   ~~~~~^~~~~~~~~~~~~~~~~
main.cpp:14:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   14 |     scanf("%s", s+i*w);
      |     ~~~~~^~~~~~~~~~~~~

ソースコード

diff #

#include <stdio.h>
#include <string.h>

#define N 50

char s[N*N+1], ss[N*N+1];

int main() {
  int h, w, i, j;
  char *p;

  scanf("%d %d", &h, &w);
  for (i = 0; i < h; i++) {
    scanf("%s", s+i*w);
  }
  strcpy(ss, s);
  p = strchr(ss, '#');
  if (p == NULL) {
    puts("NO\n");
    return 0;
  }
  for (i = 1; p[i] != '\0'; i++) {
    for (j = 0; p[i+j] != '\0'; j++) {
      if (p[j] == '#') {
        p[j] = 'R';
        if (p[i+j] != '#') break;
        p[i+j] = 'B';
      }
    }
    if (strchr(p, '#') == NULL) {
      puts("YES\n");
      return 0;
    }
    strcpy(ss, s);
  }
  puts("NO\n");

  return 0;
}
0