結果
| 問題 |
No.197 手品
|
| コンテスト | |
| ユーザー |
noorbeh
|
| 提出日時 | 2015-04-29 03:29:44 |
| 言語 | C90 (gcc 12.3.0) |
| 結果 |
AC
|
| 実行時間 | 1 ms / 1,000 ms |
| コード長 | 1,013 bytes |
| コンパイル時間 | 90 ms |
| コンパイル使用メモリ | 21,632 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-06-27 08:45:49 |
| 合計ジャッジ時間 | 1,175 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 43 |
コンパイルメッセージ
main.c: In function ‘main’:
main.c:7:3: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
7 | scanf("%s", s);
| ^~~~~~~~~~~~~~
main.c:8:3: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
8 | scanf("%d", &n);
| ^~~~~~~~~~~~~~~
main.c:9:3: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
9 | scanf("%s", t);
| ^~~~~~~~~~~~~~
ソースコード
#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