結果
| 問題 |
No.197 手品
|
| コンテスト | |
| ユーザー |
noorbeh
|
| 提出日時 | 2015-04-29 03:30:15 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 1 ms / 1,000 ms |
| コード長 | 1,013 bytes |
| コンパイル時間 | 147 ms |
| コンパイル使用メモリ | 23,552 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-07-20 03:36:20 |
| 合計ジャッジ時間 | 1,262 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 43 |
コンパイルメッセージ
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 == 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 ) ? 0 : 1;
break;
case 6:
res = ( b == 5 || b == 6 ) ? 0 : 1;
break;
}
}
if ( res ) {
printf("SUCCESS\n");
} else {
printf("FAILURE\n");
}
}
noorbeh