문제 링크: https://www.acmicpc.net/problem/5947
5947번: Book Club
Bessie is looking for cows to join her book club. While the herd has N (2 <= N <= 50,000) cows conveniently numbered 1..N, she wants only the most discerning and social cows for her book club. Thus, like a dating service, she has created a questionnaire an
www.acmicpc.net
주어진 조건 p개를 모두 만족하는 cow의 수를 세면 됨.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
#include <bits/stdc++.h>
using namespace std;
int n, q, p, a[50001][51], check[50001];
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cin >> n >> q >> p;
for(int i = 1; i <= n; i++) for(int j = 1; j <= q; j++)
cin >> a[i][j];
for(int i = 0; i < p; i++) {
int qj, aj;
cin >> qj >> aj;
for(int j = 1; j <= n; j++) {
if(a[j][qj] == aj)
check[j]++;
}
}
int ans = 0;
for(int i = 1; i <= n; i++) {
if(check[i] == p)
ans++;
}
cout << ans << '\n';
return 0;
}
http://colorscripter.com/info#e" target="_blank" style="color:#4f4f4ftext-decoration:none">Colored by Color Scripter
|
'USACO > Bronze' 카테고리의 다른 글
백준 5949 Adding Commas (USACO December 2010 Bronze 3번) (0) | 2020.04.06 |
---|---|
백준 5948 Bad Random Numbers (USACO December 2010 Bronze 2번) (0) | 2020.04.06 |
백준 5940 Math Practice (USACO November 2010 Bronze 3번) (0) | 2020.03.24 |
백준 5939 Race Results (USACO November 2010 Bronze 2번) (0) | 2020.03.24 |
백준 5938 Daisy Chains in the Field (USACO November 2010 Bronze 1번) (0) | 2020.03.24 |