結果

問題 No.1056 2D Lamps
ユーザー chocorusk
提出日時 2020-05-15 23:07:05
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 238 ms / 3,000 ms
コード長 1,823 bytes
コンパイル時間 1,496 ms
コンパイル使用メモリ 128,148 KB
最終ジャッジ日時 2025-01-10 12:09:39
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 14
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:63:37: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   63 |         for(int i=0; i<n; i++) scanf("%s", s0[i]);
      |                                ~~~~~^~~~~~~~~~~~~
main.cpp:65:45: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   65 |                 for(int j=0; j<n; j++) scanf("%s", s[j]);
      |                                        ~~~~~^~~~~~~~~~~~

ソースコード

diff #

#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#include <list>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
char s[202][202];
char s0[202][202];
const int MAX=40000; //max of width
using BS=bitset<MAX>;
void Gauss_Jordan(vector<BS> &v, vector<BS> &b){
    int n=v.size(), m=b.size();
    //vector<BS> ret=v;
    int d=0;
    for(int k=0; k<MAX; k++){
        int p=-1;
        for(int i=d; i<n; i++){
            if(v[i][k]){
                p=i;
                break;
            }
        }
        if(p==-1) continue;
        swap(v[d], v[p]);
        for(int i=0; i<n; i++){
            if(i==d) continue;
            if(v[i][k]) v[i]^=v[d];
        }
		for(int i=0; i<m; i++){
            if(b[i][k]) b[i]^=v[d];
        }
        d++;
    }
}
int main()
{
	int n, m;
	cin>>n>>m;
	int n1=6*n-2;
	vector<BS> a(n1, BS(0)), b(m, BS(0));
	for(int i=0; i<n; i++) scanf("%s", s0[i]);
	for(int i=1; i<m; i++){
		for(int j=0; j<n; j++) scanf("%s", s[j]);
		for(int j=0; j<n; j++){
			for(int k=0; k<n; k++){
				if(s[j][k]!=s0[j][k]) b[i][j*n+k]=1;
			}
		}
	}
	for(int i=0; i<n; i++){
		for(int j=0; j<n; j++){
			a[i][i*n+j]=1;
			a[n+j][i*n+j]=1;
			a[2*n+i+j][i*n+j]=1;
			a[2*n+2*n-1+i-j+n-1][i*n+j]=1;
		}
	}
	Gauss_Jordan(a, b);
	for(int i=0; i<m-1; i++){
		for(int j=i+1; j<m; j++){
			if((b[i]^b[j]).none()) cout<<1;
			else cout<<0;
		}
		cout<<endl;
	}
	return 0;
}
0