結果

問題 No.1377 Half xor Half
ユーザー SSRSSSRS
提出日時 2021-02-05 22:21:12
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,399 bytes
コンパイル時間 1,516 ms
コンパイル使用メモリ 168,488 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-15 08:39:24
合計ジャッジ時間 7,467 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  string S;
  cin >> S;
  string T;
  cin >> T;
  string S2;
  for (int i = 0; i < N; i++){
    if (S[i] == '0' && S[N + i] == '0'){
      S2 += '#';
    }
    if (S[i] == '0' && S[N + i] == '1'){
      S2 += 'A';
    }
    if (S[i] == '1' && S[N + i] == '0'){
      S2 += 'B';
    }
    if (S[i] == '1' && S[N + i] == '1'){
      S2 += 'C';
    }
  }
  string T2;
  for (int i = 0; i < N; i++){
    if (T[i] == '0' && T[N + i] == '0'){
      T2 += '#';
    }
    if (T[i] == '0' && T[N + i] == '1'){
      T2 += 'A';
    }
    if (T[i] == '1' && T[N + i] == '0'){
      T2 += 'B';
    }
    if (T[i] == '1' && T[N + i] == '1'){
      T2 += 'C';
    }
  }
  bool ok = true;
  vector<int> x;
  for (int i = 0; i < N; i++){
    if (S2[i] != T2[i]){
      if (S2[i] == '#' || T2[i] == '#'){
        ok = false;
      }
      if (S2[i] == 'A' && T2[i] == 'B' || S2[i] == 'B' && T2[i] == 'C' || S2[i] == 'C' && T2[i] == 'A'){
        x.push_back(i + 1);
        x.push_back(i);
      }
      if (S2[i] == 'A' && T2[i] == 'C' || S2[i] == 'C' && T2[i] == 'B' || S2[i] == 'B' && T2[i] == 'A'){
        x.push_back(i);
        x.push_back(i + 1);
      }
    }
  }
  if (!ok){
    cout << -1 << endl;
  } else {
    int M = x.size();
    cout << M << endl;
    for (int i = 0; i < M; i++){
      cout << x[i] << endl;
    }
  }
}
0