結果
問題 | No.197 手品 |
ユーザー |
![]() |
提出日時 | 2015-05-23 12:26:17 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 1 ms / 1,000 ms |
コード長 | 762 bytes |
コンパイル時間 | 187 ms |
コンパイル使用メモリ | 23,680 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-07-20 03:40:05 |
合計ジャッジ時間 | 1,429 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 43 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:6:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 6 | scanf("%s",before); | ~~~~~^~~~~~~~~~~~~ main.cpp:7:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 7 | int n; scanf("%d",&n); | ~~~~~^~~~~~~~~ main.cpp:8:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 8 | scanf(" %s",after); | ~~~~~^~~~~~~~~~~~~
ソースコード
#include <cstdio> #include <cstring> using namespace std; int main(){ char before[4],after[4]; scanf("%s",before); int n; scanf("%d",&n); scanf(" %s",after); short bo=0,ao=0; for(int i=0;i<3;i++){ if(before[i]=='o') bo++; if(after[i]=='o') ao++; } if(bo!=ao) printf("SUCCESS\n"); else{ if(n==0){ if(strcmp(before,after)==0) printf("FAILURE\n"); else printf("SUCCESS\n"); } else if(n==1){ char be2[4]; sprintf(be2,"%c%c%c",before[0],before[2],before[1]); char be3[4]; sprintf(be3,"%c%c%c",before[1],before[0],before[2]); before[3]='\0'; after[3]='\0'; be2[3]='\0'; be3[3]='\0'; if(strcmp(be2,after)==0||strcmp(be3,after)==0) printf("FAILURE\n"); else printf("SUCCESS\n"); } else printf("FAILURE\n"); } return 0; }