結果
| 問題 | 
                            No.179 塗り分け
                             | 
                    
| コンテスト | |
| ユーザー | 
                             tyabu
                         | 
                    
| 提出日時 | 2016-07-27 10:27:11 | 
| 言語 | C++11(廃止可能性あり)  (gcc 13.3.0)  | 
                    
| 結果 | 
                             
                                WA
                                 
                             
                            
                            (最新)
                                AC
                                 
                             
                            (最初)
                            
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 689 bytes | 
| コンパイル時間 | 237 ms | 
| コンパイル使用メモリ | 23,680 KB | 
| 実行使用メモリ | 6,824 KB | 
| 最終ジャッジ日時 | 2024-10-06 04:37:49 | 
| 合計ジャッジ時間 | 1,832 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge4 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | WA * 6 | 
| other | WA * 40 | 
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:11:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   11 |   scanf("%d %d", &h, &w);
      |   ~~~~~^~~~~~~~~~~~~~~~~
main.cpp:13:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   13 |     scanf("%s", s+i*w);
      |     ~~~~~^~~~~~~~~~~~~
            
            ソースコード
#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, dh;
  scanf("%d %d", &h, &w);
  for (i = 0; i < h; i++) {
    scanf("%s", s+i*w);
  }
  if (strchr(s, '#') != NULL) {
    strcpy(ss, s);
    for (i = 1; s[i] != '\0'; i++) {
      dh = -1;
      for (j = 0; s[i+j] != '\0'; j++) {
        if (s[j] != '#') continue;
        if (dh < 0) dh = (i+j)/w - j/w;
        s[j] = 'R';
        if ((i+j)/w - j/w != dh) break;
        if (s[i+j] != '#') break;
        s[i+j] = 'B';
      }
      if (strchr(s, '#') == NULL) {
        puts("YES\n");
        return 0;
      }
      strcpy(s, ss);
    }
  }
  puts("NO\n");
  return 0;
}
            
            
            
        
            
tyabu