結果

問題 No.1589 Bit Vector
ユーザー SSRSSSRS
提出日時 2021-07-08 23:01:04
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,514 bytes
コンパイル時間 1,827 ms
コンパイル使用メモリ 181,736 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-14 05:28:14
合計ジャッジ時間 9,268 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
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 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 RE -
testcase_21 RE -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 AC 2 ms
4,380 KB
testcase_26 AC 2 ms
4,376 KB
testcase_27 RE -
testcase_28 RE -
testcase_29 RE -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
int main(){
  int N, K;
  cin >> N >> K;
  int T;
  cin >> T;
  vector<vector<int>> C(T, vector<int>(N));
  for (int i = 0; i < T; i++){
    for (int j = 0; j < N; j++){
      cin >> C[i][j];
    }
  }
  vector<tuple<string, int, int, int>> op;
  for (int i = 0; i < T; i++){
    vector<int> p;
    for (int j = 0; j < N; j++){
      if (C[i][j] == 1){
        p.push_back(j);
      }
    }
    if (p.size() >= K){
      vector<bool> A(N, false);
      for (int j = 0; j < K; j++){
        A[p[j]] = true;
      }
      op.push_back(make_tuple("UPD", N, 1, 0));
      for (int j = 0; j < K; j++){
        op.push_back(make_tuple("AND", N, p[j], N));
      }
      op.push_back(make_tuple("XOR", N, p[0], N));
      for (int j = 0; j < N; j++){
        if (!A[j]){
          op.push_back(make_tuple("XOR", j, p[0], j));
          op.push_back(make_tuple("AND", j, N, N));
          op.push_back(make_tuple("XOR", j, p[0], j));
        }
      }
    }
  }
  int cnt = op.size();
  assert(cnt <= 10000);
  cout << cnt << endl;
  for (int i = 0; i < cnt; i++){
    if (get<0>(op[i]) == "UPD"){
      cout << "UPD " << get<1>(op[i]) + 1 << ' ' << get<2>(op[i]) << endl;
    }
    if (get<0>(op[i]) == "AND"){
      cout << "AND " << get<1>(op[i]) + 1 << ' ' << get<2>(op[i]) + 1 << ' ' << get<3>(op[i]) + 1 << endl;
    }
    if (get<0>(op[i]) == "XOR"){
      cout << "XOR " << get<1>(op[i]) + 1 << ' ' << get<2>(op[i]) + 1 << ' ' << get<3>(op[i]) + 1 << endl;
    }
  }
}
0