QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#700779#5087. Shuffle Gametamthegod#WA 0ms3940kbC++231.6kb2024-11-02 13:23:142024-11-02 13:23:25

Judging History

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

  • [2024-11-02 13:23:25]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3940kb
  • [2024-11-02 13:23:14]
  • 提交

answer

#include<bits/stdc++.h>

#define pb push_back
#define fi first
#define se second
using namespace std;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const int maxN = 500 + 5;
const int mod = 1e9 + 7;
const ll oo = 1e7;
int n, p, q;
string a[maxN], b[maxN], c[maxN];
void ReadInput()
{
    cin >> n >> p >> q;
    for(int i=1; i<=n; i++)
        cin >> a[i];
    for(int i=1; i<=p; i++)
        cin >> b[i];
    for(int i=1; i<=q; i++)
        cin >> c[i];
}
void Solve()
{
    vector<vector<vector<int>>> f(n + 1, vector<vector<int>> (p + 1, vector<int> (q + 1, 0)));
    f[0][0][0] = 0;
   // cout << f[n][p][q];return;
    for(int i=1; i<=n; i++)
        for(int j=0; j<=p; j++)
            for(int k=0; k<=q; k++)
            {
                f[i][j][k] = f[i - 1][j][k];
                if(j) f[i][j][k] = max(f[i][j][k], f[i - 1][j - 1][k] + (b[j] == a[i]));
                if(k) f[i][j][k] = max(f[i][j][k], f[i - 1][j][k - 1] + (c[k] == a[i]));
            }

    int res = 0;
    for(int i=0; i<=n; i++)
        for(int j=0; j<=p; j++)
            for(int k=0; k<=q; k++)
                res = max(res, f[i][j][k]);
    cout << res;
}
#define taskname "sol"
int32_t main()
{
    if (fopen(taskname ".inp", "r"))
    {
        freopen(taskname ".inp", "r", stdin);
       // freopen(taskname ".out", "w", stdout);
    }
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int T = 1;
    //cin >> T;
    for(int itest=1; itest<=T; itest++)
    {
        ReadInput();
        Solve();
    }
}


Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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: 3764kb

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: 3696kb

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: 3768kb

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: 3668kb

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: 3696kb

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: 0
Accepted
time: 0ms
memory: 3704kb

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:

10

result:

ok single line: '10'

Test #8:

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

input:

10 9 1
H10 D8 HA H3 H3 HK DA HQ DJ SK
SK DJ HQ DA HK H3 H3 HA D8
H10

output:

3

result:

ok single line: '3'

Test #9:

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

input:

10 9 1
C9 HJ SJ SK D5 H9 HA HK DJ C6
C6 DJ HK HA H9 D5 SK SJ C9
HJ

output:

2

result:

ok single line: '2'

Test #10:

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

input:

20 1 19
HQ D4 S10 C10 C6 C10 S8 D10 D10 C9 C6 D7 CQ HQ H7 C5 HQ S2 S6 C4
CQ
C10 HQ C9 S6 C4 D10 D10 S8 D4 C5 C10 H7 HQ C6 HQ S10 S2 D7 C6

output:

6

result:

wrong answer 1st lines differ - expected: '7', found: '6'