結果

問題 No.351 市松スライドパズル
ユーザー akakimidori
提出日時 2017-01-18 01:54:24
言語 C90
(gcc 12.3.0)
結果
AC  
実行時間 137 ms / 2,000 ms
コード長 592 bytes
コンパイル時間 189 ms
コンパイル使用メモリ 21,504 KB
実行使用メモリ 6,528 KB
最終ジャッジ日時 2024-09-25 03:06:41
合計ジャッジ時間 2,719 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 17
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c: In function ‘run’:
main.c:6:3: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    6 |   scanf("%d%d",&h,&w);
      |   ^~~~~~~~~~~~~~~~~~~
main.c:8:3: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    8 |   scanf("%d",&n);
      |   ^~~~~~~~~~~~~~
main.c:13:5: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   13 |     scanf("%s%d",s+i,k+i);
      |     ^~~~~~~~~~~~~~~~~~~~~

ソースコード

diff #

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

void run(void){
  int h,w;
  scanf("%d%d",&h,&w);
  int n;
  scanf("%d",&n);
  char *s=(char *)malloc(sizeof(char)*(n+1));
  int *k=(int *)malloc(sizeof(int)*n);
  int i;
  for(i=0;i<n;i++){
    scanf("%s%d",s+i,k+i);
  }
  int x=0;
  int y=0;
  for(i=n-1;i>=0;i--){
    if(s[i]=='R'){
      if(k[i]==y){
        x=(x-1>=0?x-1:x-1+w);
      }
    } else {
      if(k[i]==x){
        y=(y-1>=0?y-1:y-1+h);
      }
    }
  }
  if((x+y)%2==0){
    printf("white\n");
  } else {
    printf("black\n");
  }
  return;
}

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