문제) 백준 - Union Find - 거짓말
https://www.acmicpc.net/problem/1043
1043번: 거짓말
지민이는 파티에 가서 이야기 하는 것을 좋아한다. 파티에 갈 때마다, 지민이는 지민이가 가장 좋아하는 이야기를 한다. 지민이는 그 이야기를 말할 때, 있는 그대로 진실로 말하거나 엄청나게
www.acmicpc.net
N이 50 이하이기 때문에 알고리즘 유형이 Union Find인 것을 직감하셨으면 쉽게 풀 수 있었던 문제입니다.
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
int ans = 0; | |
for (int i = 0; i < M; ++i) { | |
bool isTrue = true; | |
for (int j = 0; j < truth.size(); ++j) | |
if (sets.find(PARTY[i][0]) == sets.find(truth[j])) | |
isTrue = false; | |
if (isTrue) | |
ans++; | |
} |
Full Code)
GitHub - Chocochip101/BOJ_Solution: BOJ Solutions
BOJ Solutions. Contribute to Chocochip101/BOJ_Solution development by creating an account on GitHub.
github.com
반응형
'PS(Problem Solving) > 백준_BOJ' 카테고리의 다른 글
[백준] 10803번 정사각형 만들기 (C++) 문제 및 풀이 (0) | 2021.12.20 |
---|---|
[백준] 1213번 - 팰린드롬 만들기 (C++) 문제 및 풀이 (0) | 2021.12.20 |
[백준] 13913번 숨바꼭질 4 (C++) 문제 및 풀이 (0) | 2021.12.14 |
[백준] 1766번 - 문제집 (C++) 문제 및 풀이 (0) | 2021.12.13 |
[백준] 4386번 - 별자리 만들기 (C++) 문제 및 풀이 (0) | 2021.12.12 |
댓글