結果

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int main(){
    int N, M;
    cin >> N >> M;
    bitset<400*400> R[200];
    for(int k=0; k<M; k++){
        int A[210][210] = {0}, B[410][410] = {0}, exist[410][410] = {0};
        char S[201][201];
        for(int i=0; i<N; i++) scanf("%s", S[i]);
        for(int i=0; i<N-1; i++) for(int j=0; j<N-1; j++){
            for(int x=i; x<=i+1; x++) for(int y=j; y<=j+1; y++) A[i][j] ^= (S[x][y] == '#');
            B[i+j][(i-j)+N-2] = A[i][j];
            exist[i+j][(i-j)+N-2] = 1;
        }
        vector<int> res;
        for(int i=0; i<2*N-2; i++) for(int j=0; j<2*N-2; j++){
            int v = 0, ex = 1;
            for(int x=i; x<=i+2; x+=2) for(int y=j; y<=j+2; y+=2){
                ex &= exist[x][y];
                v ^= B[x][y];
            }
            if(v && ex) R[k][i*2*N+j] = 1;
        }
    }
    for(int i=0; i<M-1; i++){
        for(int j=i+1; j<M; j++){
            printf("%d", (R[i] == R[j]));
        }
        printf("\n");
    }
    return 0;
}
0