Dolphins의 HelloWorld
[백준]Baekjoon1080(Greedy Algorithm) 본문
문제 링크 : https://www.acmicpc.net/problem/1080
#include <iostream> #include <vector> using namespace std; int A[50][50]; int B[50][50]; int main() { int N, M; scanf("%d %d", &N, &M); for (int i = 0; i < N; i++) { for (int j = 0; j < M; j++) { scanf("%1d", &A[i][j]); } } for (int i = 0; i < N; i++) { for (int j = 0; j < M; j++) { scanf("%1d", &B[i][j]); } } int count = 0; for (int i = 0; i < N-2; i++) { for (int j = 0; j < M-2; j++) { if (A[i][j] != B[i][j]) { count++; for (int x = i; x <= i + 2; x++) { for (int y = j; y <= j + 2; y++) { A[x][y] = 1 - A[x][y]; } } } } } for (int i = 0; i < N; i++) { for (int j = 0; j < M; j++) { if (A[i][j] != B[i][j]) count = -1; } } printf("%d\n", count); }
'Algorithm > baekjoon문제풀이' 카테고리의 다른 글
[백준]Baekjoon1654(이진 탐색) (0) | 2018.09.03 |
---|---|
[백준]Baekjoon1780(분할 정복) (0) | 2018.08.31 |
[백준]Baekjoon1783(Greedy Algorithm) (0) | 2018.08.29 |
[백준]Baekjoon10610(Greedy Algorithm) (0) | 2018.08.28 |
[백준]Baekjoon2875(Greedy Algorithm) (0) | 2018.08.28 |
Comments