PS/Baekjoon Online Judge

[백준 05753] Pascal Library [Python]

kimyoungrok 2024. 7. 5. 18:52
728x90

문제

Pascal University, one of the oldest in the country, needs to renovate its Library Building, because after all these centuries the building started to show the effects of supporting the weight of the enormous amount of books it houses.

To help in the renovation, the Alumni Association of the University decided to organize a series of fund-raising dinners, for which all alumni were invited. These events proved to be a huge success and several were organized during the past year. (One of the reasons for the success of this initiative seems to be the fact that students that went through the Pascal system of education have fond memories of that time and would love to see a renovated Pascal Library.)

The organizers maintained a spreadsheet indicating which alumni participated in each dinner. Now they want your help to determine whether any alumnus or alumna took part in all of the dinners.

입력

The input contains several test cases. The first line of a test case contains two integers N and D indicating respectively the number of alumni and the number of dinners organized (1 ≤ N ≤ 100 and 1 ≤ D ≤ 500). Alumni are identified by integers from 1 to N. Each of the next D lines describes the attendees of a dinner, and contains N integers Xi indicating if the alumnus/alumna i attended that dinner (Xi = 1) or not (Xi = 0). The end of input is indicated by N = D = 0.

출력

For each test case in the input your program must produce one line of output, containing either the word ‘yes’, in case there exists at least one alumnus/alumna that attended all dinners, or the word ‘no’ otherwise.


풀이

D번의 만찬 수에 대해 N명 중 모든 만찬에 참석한 사람이 있는지 여부를 출력하는 문제다.

우선 모든 만찬의 참석 정보를 입력받자.

입력받은 D개의 만찬에 대해 동일한 사람의 참석 정보를 AND연산하여 전부 참석한 사람을 확인하자

만찬에 모두 참석한 사람이 한명이라도 있다면 'yes'를 출력해주자.


소스코드

보기


출처

https://www.acmicpc.net/problem/5753

728x90