結果

問題 No.197 手品
ユーザー 0w10w1
提出日時 2016-11-20 20:28:03
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,375 bytes
コンパイル時間 1,619 ms
コンパイル使用メモリ 168,812 KB
実行使用メモリ 4,508 KB
最終ジャッジ日時 2023-09-09 21:07:09
合計ジャッジ時間 3,383 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 WA -
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 WA -
testcase_09 AC 1 ms
4,376 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 1 ms
4,380 KB
testcase_24 WA -
testcase_25 WA -
testcase_26 AC 1 ms
4,376 KB
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 AC 1 ms
4,380 KB
testcase_31 AC 1 ms
4,376 KB
testcase_32 AC 1 ms
4,376 KB
testcase_33 WA -
testcase_34 AC 2 ms
4,376 KB
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
testcase_40 AC 1 ms
4,376 KB
testcase_41 WA -
testcase_42 WA -
testcase_43 AC 2 ms
4,376 KB
testcase_44 WA -
testcase_45 WA -
testcase_46 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

const string msg[] = { "FAILURE", "SUCCESS" };

signed main(){
  string S1; cin >> S1;
  int N; cin >> N;
  string S2; cin >> S2;
  int ocnt = 0, xcnt = 0;
  for( int i = 0; i < S1.size(); ++i )
    ocnt += S1[ i ] == 'o',
    xcnt += S1[ i ] == 'x';
  for( int i = 0; i < S2.size(); ++i )
    ocnt -= S2[ i ] == 'o',
    xcnt -= S2[ i ] == 'x';
  if( ocnt != 0 or xcnt != 0 )
    cout << "SUCCESS" << endl,
    exit( 0 );
  if( N == 0 )
    cout << msg[ S1 != S2 ] << endl,
    exit( 0 );
  if( N < 3 ){
    string t = S1; swap( t[ 0 ], t[ 1 ] );
    if( t == S2 )
      cout << msg[ 1 ] << endl,
      exit( 0 );
  }
  N &= 1;
  if( N == 1 ){
    string t = S1;
    if( t == S2 )
      cout << msg[ 1 ] << endl, exit( 0 );
    swap( t[ 1 ], t[ 2 ] ); swap( t[ 0 ], t[ 1 ] );
    if( t == S2 )
      cout << msg[ 1 ] << endl, exit( 0 );
    t = S1;
    swap( t[ 0 ], t[ 1 ] ); swap( t[ 1 ], t[ 2 ] );
    if( t == S2 )
      cout << msg[ 1 ] << endl, exit( 0 );
  } else{
    string t = S1;
    swap( t[ 0 ], t[ 1 ] );
    if( t == S2 )
      cout << msg[ 1 ] << endl, exit( 0 );
    t = S1;
    swap( t[ 1 ], t[ 2 ] );
    if( t == S2 )
      cout << msg[ 1 ] << endl, exit( 0 );
    t = S1;
    swap( t[ 0 ], t[ 2 ] );
    if( t == S2 )
      cout << msg[ 1 ] << endl, exit( 0 );
  }
  cout << msg[ 0 ] << endl;
  return 0;
}
0