RiseOJ는 solved.ac와 제휴 관계가 없습니다. 티어 아이콘 © solved.ac. solved.ac
포럼
문제 COCI00691

Karte

설명

On Vito’s table, there are \(N\) red cards labeled with numbers from 1 to \(N\) and \(M\) blue cards labeled with
numbers from 1 to \(M\). Each pair of red and blue cards (c, p) (where \(c\) represents a red card and \(p\) a blue
card) can create a COMBO move.
The strength of a deck of cards is defined as:
strength = (number \(of\) COMBO moves) −\(X\) · (number \(of\) red cards) −\(Y\) · (number \(of\) blue cards)
where the number \(of\) COMBO moves is the number of pairs (c, p) such that the red card \(c\) and the blue
card \(p\) are in the chosen deck. Vito can include any card from the table in his deck. Help Vito find the
value of the strongest deck he can build. Vito can also choose an empty deck of cards.
Input Data
The first line contains 4 natural numbers N, M, X, Y (\(1 \le N\), \(M \le 21\), \(0 \le X\), \(Y \le 30\)).
In the next \(N\) lines, there is a sequence of \(M\) characters (0 or 1), where the \(j\)-th character indicates
whether the \(i\)-th red card and the \(j\)-th blue card create a COMBO move.
Output Data
In the first and only line, output the value of the strongest deck of cards that Vito can build.
Scoring
Subtask
Points
Constraints
1
18
\(Y = 0\)
2
11
\(1 \le N\), \(M \le 9\)
3
24
\(1 \le N\), \(M \le 15\)
4
17
No additional constraints.
Sample Cases

제약
입력 형식

2 2 0 0
11
10

출력 형식

3
input
3 3 1 0
111
111
000
output
4
input
3 3 1 1
111
101
011
output
1
Explanation of the first sample case: Vito will choose all the cards from the table, creating 3 COMBO
moves.
Explanation of the second sample case: Vito will select the first 2 red cards and all 3 blue cards,
creating 6 COMBO moves. The deck strength is 4 because Vito selected 2 red cards, so the number of
COMBO moves, i.e., 6, is reduced by 2.

예제 1
입력
2 2 0 0
11
10
출력
3
예제 2
입력
3 3 1 0
111
111
000
출력
4
예제 3
입력
3 3 1 1
111
101
011
출력
1
문제 정보

생성자가 기록되지 않았습니다.

출처 COCI 2024/2025 Contest 3

평가 및 의견

Karte

개요
출제자 난이도 Unrated 레이팅 미적용 의견 0 / 50 공개 집계 (커뮤니티 난이도, 주요 주제, 품질)는 의견이 충분히 모이면 공개됩니다.

Log in to rate problems.

개별 의견

아직 의견이 없습니다. 자격이 된다면 위 양식에서 가장 먼저 평가해 보세요.

풀이 제출

Karte

게스트로 둘러보고 있습니다. 로그인하면 풀이를 제출하고 진행 상황을 확인할 수 있습니다. 로그인하고 제출하기
공개
C++20 Tab 들여쓰기 · Ctrl+/ 주석 토글 · Enter 자동 들여쓰기
1 1 1 0 공백: 4 · UTF-8