結果
問題 |
No.197 手品
|
ユーザー |
![]() |
提出日時 | 2015-04-29 03:26:30 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,031 bytes |
コンパイル時間 | 397 ms |
コンパイル使用メモリ | 23,040 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-06-27 08:45:27 |
合計ジャッジ時間 | 1,386 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 41 WA * 2 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:7:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 7 | scanf("%s", s); | ~~~~~^~~~~~~~~ main.cpp:8:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 8 | scanf("%d", &n); | ~~~~~^~~~~~~~~~ main.cpp:9:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 9 | scanf("%s", t); | ~~~~~^~~~~~~~~ main.cpp:47:3: warning: ‘res’ may be used uninitialized in this function [-Wmaybe-uninitialized] 47 | if ( res ) { | ^~
ソースコード
#include <stdio.h> int main() { char s[4], t[4]; int i, n, a, b, res; scanf("%s", s); scanf("%d", &n); scanf("%s", t); a = b = 0; for ( i = 0; i < 3; i++ ) { a += (s[i] == 'o') << (2-i); b += (t[i] == 'o') << (2-i); } if ( n == 0 || a == 0 || a == 7 ) { res = ( a != b ) ? 1 : 0; } else if ( n > 1 ) { if ( a == 1 || a == 2 || a == 4 ) res = ( b == 1 || b == 2 || b == 4 ) ? 0 : 1; else res = ( b == 3 || b == 6 || b == 5 ) ? 0 : 1; } else { switch (a) { case 1: res = ( b == 1 || b == 2 ) ? 0 : 1; break; case 2: res = ( b == 1 || b == 2 || b == 4 ) ? 0 : 1; break; case 4: res = ( b == 2 || b == 4 ) ? 0 : 1; break; case 3: res = ( b == 3 || b == 5 ) ? 0 : 1; break; case 5: res = ( b == 3 || b == 6 || b == 5 ) ? 0 : 1; break; case 6: res = ( b == 5 || b == 6 ) ? 0 : 1; break; } } if ( res ) { printf("SUCCESS\n"); } else { printf("FAILURE\n"); } }