結果

問題 No.197 手品
ユーザー iqueue02
提出日時 2020-07-13 21:59:20
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 969 bytes
コンパイル時間 3,075 ms
コンパイル使用メモリ 194,004 KB
最終ジャッジ日時 2025-01-11 20:19:23
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 20 WA * 23
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n);i++)
#define sz(x) int(x.size())
typedef long long ll;
typedef pair<int,int> P;
constexpr int INF = 2e9;

int main() {
  string s, t;
  int n;
  cin >> s >> n >> t;
  int cnt0 = 0, cnt1 = 0;
  rep(i,3) {
    if (s[i] == 'o') cnt0++;
    if (t[i] == 'o') cnt1++;
  }
  if (cnt0 != cnt1) {
    cout << "SUCCESS" << endl;
    return 0;
  }
  int cnt = 0;
  vector<int> ok(3, 0);
  for (int i = 0; i < 3; i++) {
    if (s[i] == 'x') continue;
    int id = -1;
    for (int j = 0; j < 3; j++) {
      if (t[j] == 'x') continue;
      if (ok[j]) continue;
      if (id == -1) id = j;
      else if (abs(id - i) > abs(j - i)) {
        id = j;
      }
    }
    ok[id] = 1;
    cnt += abs(id - i);
  }
  if (n < cnt) {
    cout << "SUCCESS" << endl;
    return 0;
  }
  n -= cnt;
  if (n % 2 == 1) {
    cout << "SUCCESS" << endl;
  } else {
    cout << "FAILURE" << endl;
  }
  return 0;
}
0