※ 글쓴이는 취미로 코딩을 익혀보는 사람이라 정확하지 않은 내용을 담고 있을 수 있다 ※
이번에 볼 문제는 백준 5753번 문제인 Pascal Library이다.
문제는 아래 링크를 확인하자.
https://www.acmicpc.net/problem/5753
5753번: Pascal Library
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 renov
www.acmicpc.net
각 테스트케이스마다 모든 식사에 참가한 사람이 있는지를 판단하는 문제이다.
아래와 같이 참가하지 않은 식사가 있는지를 저장하는 배열을 얻어 문제를 해결하자.
모든 식사 정보를 저장하고 매 사람마다 식사 참여 여부를 확인하는 것으로도 문제를 충분히 해결할 수 있을 것이다.
아래는 제출한 소스코드이다.
#include <iostream>
#include <cstring>
using namespace std;
int T;
int N, D;
int chk[100];
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
cin >> N >> D;
while (N) {
bool ans = 0;
memset(chk, 0, sizeof(chk));
while (D--) {
for (int i = 0; i < N; i++) {
int x; cin >> x;
if (!x) chk[i] = 1;
}
}
for (int i = 0; i < N; i++) {
if (!chk[i]) ans = 1;
}
if (ans) cout << "yes\n";
else cout << "no\n";
cin >> N >> D;
}
}
728x90
'BOJ' 카테고리의 다른 글
[BOJ 24366 // C++] КЛЕТКИ (0) | 2023.01.07 |
---|---|
[BOJ 27058 // C++] Message Decowding (0) | 2023.01.07 |
[BOJ 23365 // C++] Buffered Buffet (1) | 2023.01.06 |
[BOJ 18813 // C++] Divisionals Spelling (1) | 2023.01.06 |
[BOJ 15429 // C++] Odd Gnome (0) | 2023.01.06 |