結果
問題 | No.1056 2D Lamps |
ユーザー |
![]() |
提出日時 | 2020-05-15 22:43:38 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 224 ms / 3,000 ms |
コード長 | 2,127 bytes |
コンパイル時間 | 2,697 ms |
コンパイル使用メモリ | 200,332 KB |
最終ジャッジ日時 | 2025-01-10 11:56:39 |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 14 |
ソースコード
#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; }