結果
| 問題 |
No.197 手品
|
| コンテスト | |
| ユーザー |
noorbeh
|
| 提出日時 | 2015-04-29 00:44:35 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 983 bytes |
| コンパイル時間 | 253 ms |
| コンパイル使用メモリ | 23,552 KB |
| 実行使用メモリ | 6,948 KB |
| 最終ジャッジ日時 | 2024-06-27 08:35:16 |
| 合計ジャッジ時間 | 1,768 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 26 WA * 17 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:9:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
9 | scanf("%s", s);
| ~~~~~^~~~~~~~~
main.cpp:10:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
10 | scanf("%ld", &n);
| ~~~~~^~~~~~~~~~~
main.cpp:11:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
11 | scanf("%s", t);
| ~~~~~^~~~~~~~~
main.cpp:55:3: warning: ‘res’ may be used uninitialized [-Wmaybe-uninitialized]
55 | if ( res ) {
| ^~
ソースコード
#include <stdio.h>
int main()
{
char s[4], t[4];
int i, a, b;
long int n;
int res;
scanf("%s", s);
scanf("%ld", &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);
}
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");
}
}
noorbeh