문제) 백준 - 구현 - 그림 비교
https://www.acmicpc.net/problem/2160
2160번: 그림 비교
N(2 ≤ N ≤ 50)개의 그림이 있다. 각각의 그림은 5×7의 크기이고, 두 가지 색으로 되어 있다. 이때 두 가지의 색을 각각 ‘X’와 ‘.’으로 표현하기로 하자. 이러한 그림들이 주어졌을 때, 가장 비
www.acmicpc.net
반복문으로 하나씩 저장 후 비교하여 가장 비슷한 것을 출력합니다.
C++ 소스코드)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <bits/stdc++.h> | |
#define endl "\n" | |
#define ll long long | |
#define INF 987654321 | |
#define MAX 51 | |
#define MOD 10007 | |
using namespace std; | |
typedef pair<int, int> p; | |
int N; | |
string board[MAX][5]; | |
int sim(int x, int y){ | |
int res = 0; | |
for(int i = 0; i < 5; ++i) | |
for(int j = 0; j < 7; ++j) | |
if(board[x][i][j] == board[y][i][j]) | |
res++; | |
return res; | |
} | |
int main() { | |
ios_base::sync_with_stdio(0); | |
cin.tie(0); cout.tie(0); | |
cin >> N; | |
for(int i = 1; i <= N; ++i) | |
for(int j = 0; j < 5; ++j) | |
cin >> board[i][j]; | |
int cnt = -1; | |
int f, s; | |
for(int i = 1; i <= N; ++i) | |
for(int j = i + 1; j <= N; ++j) | |
if(cnt < sim(i, j)){ | |
cnt = sim(i, j); | |
f = i; s = j; | |
} | |
cout << f << " " << s; | |
return 0; | |
} |
반응형
'PS(Problem Solving) > 백준_BOJ' 카테고리의 다른 글
[백준] 14722번 - 우유 도시 (C++) 문제 및 풀이 (0) | 2022.02.16 |
---|---|
[백준] 18353번 - 병사 배치하기 (C++) 문제 및 풀이 (0) | 2022.02.16 |
[백준] 21937번 - 작업 (C++) 문제 및 풀이 (0) | 2022.02.15 |
[백준] 19583번 - 싸이버개강총회 (Python) 문제 및 풀이 (0) | 2022.02.15 |
[백준] 20207번 - 달력 (C++) 문제 및 풀이 (0) | 2022.02.14 |
댓글