結果

問題 No.197 手品
ユーザー 0w1
提出日時 2016-11-20 20:28:03
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 1,375 bytes
コンパイル時間 1,565 ms
コンパイル使用メモリ 169,492 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-06-27 13:36:39
合計ジャッジ時間 2,739 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2 WA * 2
other AC * 11 WA * 32
権限があれば一括ダウンロードができます

ソースコード

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