結果

問題 No.197 手品
ユーザー noorbeh
提出日時 2015-04-29 00:21:41
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 1,049 bytes
コンパイル時間 122 ms
コンパイル使用メモリ 23,296 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-06-27 08:13:46
合計ジャッジ時間 1,301 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 24 WA * 19
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:8:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    8 |   scanf("%s", s);
      |   ~~~~~^~~~~~~~~
main.cpp:9:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    9 |   scanf("%d", &n);
      |   ~~~~~^~~~~~~~~~
main.cpp:10:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   10 |   scanf("%s", t);
      |   ~~~~~^~~~~~~~~
main.cpp:58:3: warning: ‘res’ may be used uninitialized [-Wmaybe-uninitialized]
   58 |   if ( res )
      |   ^~

ソースコード

diff #

#include <stdio.h>

int main()
{
  char s[4], t[4];
  int i, n, a, b;
  int res;
  scanf("%s", s);
  scanf("%d", &n);
  scanf("%s", t);

  a = b = 0;
  for ( i = 0; i < 4; i++ ) {
    a += (s[i] == 'o') << (2-i);
    b += (t[i] == 'o') << (2-i);
  }
  /*
  printf("n = %d\n", n);
  printf("%s %d\n", s, a);
  printf("%s %d\n", t, b);
  */
  switch ( a ) {
  case 0:
  case 7:
    res = ( b != a ) ? 1 : 0;
    break;
  case 1:
  case 4:
    if ( n % 2 ) {
      res = ( b != 2 ) ? 1 : 0;
    } else {
      res = ( !(b == 1 || b == 4)  ) ? 1 : 0;
    }
    break;
  case 3:
  case 6:
    if ( n % 2 ) {
      res = ( b != 5 ) ? 1 : 0;
    } else {
      res = ( !(b == 3 || b == 6) ) ? 1 : 0;
    }
    break;
  case 2:
    if ( n % 2 ) {
      res = ( !(b == 1 || b == 4)  ) ? 1 : 0;
    } else {
      res = ( b != 2 ) ? 1 : 0;
    }
    break;
  case 5:
    if ( n % 5 ) {
      res = ( !(b == 3 && b == 6)  ) ? 1 : 0;
    } else {
      res = ( b != 5 ) ? 1 : 0;
    }
  }

  if ( res )
    printf("SUCCESS\n");
  else
    printf("FAILURE\n");
}
0