QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#742957#5087. Shuffle Gameucup-team5062#WA 0ms3748kbC++201.0kb2024-11-13 17:44:542024-11-13 17:44:55

Judging History

你现在查看的是最新测评结果

  • [2024-11-13 17:44:55]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3748kb
  • [2024-11-13 17:44:54]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

template <class T> bool chmax(T& x, const T& y) { return x < y && (x = y, true); }

int main() {
    cin.tie(nullptr)->sync_with_stdio(false);

    int N, M, K;
    cin >> N >> M >> K;
    vector<string> X(N), Y(M), Z(K);
    for (auto& x : X) cin >> x;
    for (auto& x : Y) cin >> x;
    for (auto& x : Z) cin >> x;

    vector dp(N + 1, vector(M + 1, vector(K + 1, 0)));
    for (int i = 0; i <= N; ++i) {
        for (int j = 0; j <= M; ++j) {
            for (int k = 0; k <= K; ++k) {
                if (i < N) chmax(dp[i + 1][j][k], dp[i][j][k]);
                if (j < M) chmax(dp[i][j + 1][k], dp[i][j][k]);
                if (k < K) chmax(dp[i][j][k + 1], dp[i][j][k]);
                if (i < N && j < M && X[i] == Y[j]) chmax(dp[i + 1][j + 1][k], dp[i][j][k] + 1);
                if (i < N && j < K && X[i] == Z[k]) chmax(dp[i + 1][j][k + 1], dp[i][j][k] + 1);
            }
        }
    }
    cout << dp[N][M][K] << '\n';

    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3748kb

input:

5 2 3
CJ D5 HA C2 S7
D5 HA
CJ S7 C2

output:

4

result:

ok single line: '4'

Test #2:

score: 0
Accepted
time: 0ms
memory: 3540kb

input:

6 3 3
C9 HK SQ SQ H2 CA
CA HK SQ
H2 C9 SQ

output:

4

result:

ok single line: '4'

Test #3:

score: 0
Accepted
time: 0ms
memory: 3480kb

input:

7 3 4
S9 C10 DJ S6 S7 SA DQ
DJ S6 S7
S9 C10 SA DQ

output:

7

result:

ok single line: '7'

Test #4:

score: 0
Accepted
time: 0ms
memory: 3588kb

input:

10 1 9
CJ CJ CJ CJ CJ CJ CJ CJ CJ CJ
CJ
CJ CJ CJ CJ CJ CJ CJ CJ CJ

output:

10

result:

ok single line: '10'

Test #5:

score: 0
Accepted
time: 0ms
memory: 3552kb

input:

10 4 6
D2 D2 D2 D2 D2 D2 D2 D2 D2 D2
D2 D2 D2 D2
D2 D2 D2 D2 D2 D2

output:

10

result:

ok single line: '10'

Test #6:

score: 0
Accepted
time: 0ms
memory: 3532kb

input:

10 3 7
C7 C9 S6 C8 SK C3 DJ S7 H4 CA
S6 C8 C3
C7 C9 SK DJ S7 H4 CA

output:

10

result:

ok single line: '10'

Test #7:

score: -100
Wrong Answer
time: 0ms
memory: 3488kb

input:

10 8 2
HQ H2 C10 D5 C5 C6 C6 S4 DJ D8
HQ H2 C10 D5 C5 C6 S4 DJ
C6 D8

output:

8

result:

wrong answer 1st lines differ - expected: '10', found: '8'