結果

問題 No.1056 2D Lamps
ユーザー Ryuhei MoriRyuhei Mori
提出日時 2020-05-20 20:25:56
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 173 ms / 3,000 ms
コード長 1,330 bytes
コンパイル時間 765 ms
コンパイル使用メモリ 74,620 KB
実行使用メモリ 14,824 KB
最終ジャッジ日時 2024-04-09 23:05:42
合計ジャッジ時間 3,773 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,816 KB
testcase_01 AC 2 ms
6,940 KB
testcase_02 AC 2 ms
6,944 KB
testcase_03 AC 165 ms
13,560 KB
testcase_04 AC 163 ms
13,952 KB
testcase_05 AC 163 ms
14,824 KB
testcase_06 AC 163 ms
14,016 KB
testcase_07 AC 173 ms
13,884 KB
testcase_08 AC 173 ms
14,192 KB
testcase_09 AC 62 ms
14,132 KB
testcase_10 AC 94 ms
13,652 KB
testcase_11 AC 166 ms
13,612 KB
testcase_12 AC 162 ms
14,588 KB
testcase_13 AC 2 ms
6,940 KB
testcase_14 AC 15 ms
6,940 KB
testcase_15 AC 10 ms
6,944 KB
testcase_16 AC 7 ms
6,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#include <bitset>
#include <vector>

using u64 = unsigned long long int;

using vec = std::bitset<40000>;
using bvec = std::pair<vec, int>;

int n, m;

std::vector<bvec> basis;


void strip(vec& x){
  for(auto const &b: basis)
    if(x.test(b.second)) x ^= b.first;
}

void add_to_basis(vec& x){
  strip(x);
  if(x.any()) basis.emplace_back(x, x._Find_first());
}

int main(){
  scanf("%d%d", &n, &m);

  for(int i = 0; i < n; i++){
    vec x, y;
    for(int j = 0; j < n; j++){
      x.set(n * i + j);
      y.set(n * j + i);
    }
    add_to_basis(x);
    add_to_basis(y);
  }
  for(int i = 0; i < 2*n-1; i++){
    vec x, y;
    for(int j = std::max(0, i-n+1); j <= std::min(i, n-1); j++){
      x.set(n * j + i-j);
    }
    for(int j = std::max(0, n-1-i); j <= std::min(2*n-2-i, n-1); j++){
      y.set(n * j + i+j-n+1);
    }
    add_to_basis(x);
    add_to_basis(y);
  }

  std::vector<vec> q;
  for(int i = 0; i < m; i++){
    vec x;
    for(int j = 0; j < n; j++){
      for(int k = 0; k < n; k++){
        char c;
        do { c = getchar(); } while(c != '.' && c != '#');
        if(c == '#') x.set(n * j + k);
      }
    }
    strip(x);
    q.push_back(x);
  }
  for(int i = 0; i < m-1; i++){
    for(int j = i+1; j < m; j++){
      printf("%d", q[i] == q[j]);
    }
    puts("");
  }

  return 0;
}
0