結果

問題 No.1056 2D Lamps
ユーザー beetbeet
提出日時 2020-05-15 22:43:38
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 166 ms / 3,000 ms
コード長 2,127 bytes
コンパイル時間 2,607 ms
コンパイル使用メモリ 209,748 KB
実行使用メモリ 17,820 KB
最終ジャッジ日時 2023-10-19 15:47:26
合計ジャッジ時間 5,529 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 6 ms
17,692 KB
testcase_01 AC 6 ms
17,688 KB
testcase_02 AC 6 ms
17,684 KB
testcase_03 AC 162 ms
17,820 KB
testcase_04 AC 163 ms
17,820 KB
testcase_05 AC 164 ms
17,820 KB
testcase_06 AC 166 ms
17,820 KB
testcase_07 AC 165 ms
17,820 KB
testcase_08 AC 162 ms
17,820 KB
testcase_09 AC 152 ms
17,820 KB
testcase_10 AC 91 ms
17,820 KB
testcase_11 AC 164 ms
17,820 KB
testcase_12 AC 166 ms
17,820 KB
testcase_13 AC 6 ms
17,688 KB
testcase_14 AC 7 ms
17,768 KB
testcase_15 AC 7 ms
17,768 KB
testcase_16 AC 7 ms
17,768 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
using Int = long long;
const char newl = '\n';

//INSERT ABOVE HERE

const size_t B = 20;
struct ull{
  array<unsigned long long, B> dat;
  bool operator==(const ull&a)const{return dat==a.dat;};
  bool operator!=(const ull&a)const{return dat!=a.dat;};

  bool operator<(const ull&a)const{return dat<a.dat;};
  bool operator>(const ull&a)const{return dat>a.dat;};

  ull(){for(int i=0;i<(int)B;i++) dat[i]=0;}
  ull(unsigned long long a){
    for(int i=0;i<(int)B;i++) dat[i]=0;
    dat[B-1]=a;
  }

  ull& operator^=(const ull&a){
    for(int i=0;i<(int)B;i++) dat[i]^=a.dat[i];
    return *this;
  }
  ull operator^(const ull&a)const{
    return ull(*this)^=a;
  }
};

ull rnd[300][300];

vector<ull> vs;
void add(ull v){
  for(ull b:vs) chmin(v,v^b);
  if(v!=ull(0)) vs.emplace_back(v);
}

void init(int n){
  mt19937_64 mt(1333);
  for(int i=0;i<n;i++)
    for(int j=0;j<n;j++)
      for(int k=0;k<(int)B;k++)
        rnd[i][j].dat[k]=mt();

  for(int i=0;i<n;i++){
    ull res=0;
    for(int j=0;j<n;j++)
      res^=rnd[i][j];
    add(res);
  }

  for(int j=0;j<n;j++){
    ull res=0;
    for(int i=0;i<n;i++)
      res^=rnd[i][j];
    add(res);
  }

  for(int k=0;k<n*2;k++){
    ull res=0;
    for(int i=0;i<n;i++)
      for(int j=0;j<n;j++)
        if(i+j==k) res^=rnd[i][j];
    add(res);
  }

  for(int k=-n;k<n;k++){
    ull res=0;
    for(int i=0;i<n;i++)
      for(int j=0;j<n;j++)
        if(i-j==k) res^=rnd[i][j];
    add(res);
  }
}

ull input(int n){
  ull res=0;
  for(int i=0;i<n;i++){
    string s;
    cin>>s;
    for(int j=0;j<n;j++)
      if(s[j]=='.') res^=rnd[i][j];
  }
  for(ull b:vs) chmax(res,res^b);
  return res;
}

signed main(){
  cin.tie(0);
  ios::sync_with_stdio(0);

  int n,m;
  cin>>n>>m;

  init(n);

  vector<ull> vs;
  for(int i=0;i<m;i++) vs.emplace_back(input(n));

  for(int i=0;i+1<m;i++){
    for(int j=i+1;j<m;j++)
      cout<<(vs[i]==vs[j]);
    cout<<newl;
  }
  return 0;
}
0