QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#533861#5087. Shuffle GamePrimesz#AC ✓300ms370636kbC++201.6kb2024-08-26 15:39:582024-08-26 15:40:02

Judging History

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

  • [2024-08-26 15:40:02]
  • 评测
  • 测评结果:AC
  • 用时:300ms
  • 内存:370636kb
  • [2024-08-26 15:39:58]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;

#define pb push_back
#define fs first
#define sc second
#define sz(x) (int)(x.size())
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, ll> pil;
typedef pair<ll, ll> pll;
typedef priority_queue <ll, vector<ll>, greater<ll>> pqmin;
const double EPS = 1e-16;
const int INF = 2e9;
const int MOD = 1e9+7;

const int p=505;
int dp[p][p][p];
string s1[p];
string s2[p];
string s3[p];

void solve(){
    int n,m1,m2;
    cin>>n>>m1>>m2;
    for(int i=1;i<=n;i++){
        cin>>s1[i];
    }
    for(int i=1;i<=m1;i++){
        cin>>s2[i];
    }
    for(int i=1;i<=m2;i++){
        cin>>s3[i];
    }
    for(int i=0;i<=n;i++){
        for(int j=0;j<=m1;j++){
            for(int k=0;k<=m2;k++){
                if(i!=0){
                    dp[i][j][k]=max(dp[i][j][k],dp[i-1][j][k]);
                }
                if(j!=0){
                    dp[i][j][k]=max(dp[i][j][k],dp[i][j-1][k]);
                    if(s1[i]==s2[j]){
                        dp[i][j][k]=max(dp[i][j][k],dp[i-1][j-1][k]+1);
                    }
                }
                if(k!=0){
                    dp[i][j][k]=max(dp[i][j][k],dp[i][j][k-1]);
                    if(s1[i]==s3[k]){
                        dp[i][j][k]=max(dp[i][j][k],dp[i-1][j][k-1]+1);
                    }
                }
            }
        }
    }
    cout<<dp[n][m1][m2]<<endl;
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    int t=1;

    while(t--){
        solve();
    }

    cin.get();
    return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 1ms
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: 3720kb

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: 1ms
memory: 3760kb

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

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: 1ms
memory: 3872kb

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: 1ms
memory: 3776kb

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: 1ms
memory: 3848kb

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: 1ms
memory: 3912kb

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: 1ms
memory: 3896kb

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

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:

7

result:

ok single line: '7'

Test #11:

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

input:

20 10 10
D7 SJ DA CA C7 SK H10 CK D8 DQ D2 DJ H10 C7 C5 HJ CQ S4 DK H3
SK DQ SJ CQ DK S4 C7 C7 CK CA
D2 D8 DA H10 DJ C5 HJ H10 D7 H3

output:

10

result:

ok single line: '10'

Test #12:

score: 0
Accepted
time: 1ms
memory: 4396kb

input:

20 15 5
SJ CK D5 S10 H5 D8 H8 C5 SQ C10 D10 CA DQ H7 C3 H10 C7 SJ S10 D8
SJ D5 D8 H10 C3 C7 S10 H5 H8 DQ D8 SJ CK SQ H7
S10 C10 C5 D10 CA

output:

11

result:

ok single line: '11'

Test #13:

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

input:

20 19 1
S2 S2 S4 D4 H5 S10 H2 S4 D2 HK H4 S9 SJ D4 CK H2 S4 H2 D9 D9
H5 D9 H4 D4 S4 S2 D9 H2 S2 H2 H2 S4 HK SJ S10 CK S4 D2 D4
S9

output:

9

result:

ok single line: '9'

Test #14:

score: 0
Accepted
time: 1ms
memory: 4500kb

input:

50 6 44
CK D9 H2 D7 S6 HK S2 C2 D6 D10 HQ S6 H8 D6 SK C10 D5 C10 HJ S2 HK H6 D4 D4 CA S6 HQ H9 C7 C9 S7 S3 C10 H4 C2 D5 D4 D2 D8 C6 D9 S4 D4 C10 H5 SQ C4 C3 DJ SJ
SJ S6 SK D5 HQ HK
S2 H9 H4 S6 D5 H2 D9 D6 D8 C10 D2 C7 HQ D6 H5 C9 C10 S4 SQ H6 C3 D4 D7 C10 S3 HJ C10 CK D4 S2 S7 C6 C2 D4 H8 S6 C2 C4 D...

output:

18

result:

ok single line: '18'

Test #15:

score: 0
Accepted
time: 1ms
memory: 5052kb

input:

50 12 38
D8 C7 CJ S2 S9 H4 CQ C5 S2 S5 C5 C6 C3 DA D8 H5 S6 CJ C7 D7 C10 SJ DJ D10 CK S9 D4 HQ CK S2 C8 S9 CQ SA C3 CK DJ D7 C9 C4 C8 S9 HJ C3 C10 S7 D5 H5 C9 D2
C4 HQ C9 C7 C3 C5 S9 S9 C3 S9 DA S2
DJ D4 D2 D8 S6 DJ CQ S2 H5 D7 C5 C9 SJ D10 CK SA CK C8 CQ H4 D7 C10 CK D8 S9 C8 C3 CJ CJ C10 C6 S2 HJ ...

output:

22

result:

ok single line: '22'

Test #16:

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

input:

50 15 35
D3 S5 S5 S4 S4 H9 H3 H9 DJ C7 D5 S10 S10 CK H6 HJ H9 S2 D10 C10 C3 H7 D5 DQ H3 SQ D8 C9 D8 DJ SQ H4 HJ D6 CQ CJ H2 DK H3 C9 S6 DQ C4 C4 D9 D8 H3 S8 D10 C7
D3 H3 S5 CJ H4 C9 C3 D5 S5 D8 HJ C10 C4 H3 D9
H2 C9 C7 HJ D5 H3 SQ C7 DK H6 D10 H9 DQ S2 DJ S4 S10 D8 SQ H9 DJ D8 S8 CK C4 S6 H7 S4 DQ H...

output:

19

result:

ok single line: '19'

Test #17:

score: 0
Accepted
time: 3ms
memory: 7092kb

input:

50 32 18
SA CK C6 SQ S6 S10 H2 DA SQ SA HQ CQ D7 S10 C9 HA H2 D3 S4 S10 CA D7 CQ DK DJ CK H10 H9 H3 DA D5 DA CA S6 SJ D2 S9 D5 H8 CJ H7 DK C6 H4 DQ H2 D4 S9 S8 H2
DK H2 S6 CQ C9 CQ CA H7 D2 H2 SQ H2 DJ CA H2 S9 S10 DQ DK H3 D5 D5 CK C6 D7 C6 CK SA H4 SQ S10 S9
HA SJ HQ SA CJ S10 D3 D4 H8 D7 S8 DA H1...

output:

20

result:

ok single line: '20'

Test #18:

score: 0
Accepted
time: 3ms
memory: 7420kb

input:

50 35 15
S5 S9 SK C2 SQ S2 C4 S2 CK CJ S6 S10 SJ S6 D7 SA DJ D4 D7 SJ C4 C6 C6 D9 S5 CK HQ C5 SK S9 CK D6 S10 D9 SA D3 D7 D10 C2 C5 HJ S8 H10 H5 DJ C7 H2 C8 D9 DK
C4 C5 S2 H2 S8 D9 SQ SJ S5 SK C4 D7 D9 DJ S2 SJ SA D3 C8 S10 DJ HJ D7 S5 S10 C2 S6 CJ S9 H5 C7 C6 CK D10 SK
HQ C2 D9 H10 D4 DK CK CK S6 D...

output:

21

result:

ok single line: '21'

Test #19:

score: 0
Accepted
time: 4ms
memory: 12500kb

input:

100 42 58
C3 D4 HA S3 DJ CK S8 H9 SQ D4 D6 HK CK C5 S8 S8 C2 C5 SA C2 S10 C7 C10 S2 C10 HA S6 D2 DQ S10 SQ C3 C6 DA D6 CK S7 C8 D3 SK D7 H3 S7 D2 S9 S9 H5 C8 D9 DA DK C3 HA D10 D6 CK SK DK C4 C2 C6 CA D5 D10 DJ C3 HA CJ SA S5 C5 S6 D4 HA S4 S7 SJ D3 SJ CJ H10 H7 C5 CQ H5 HJ S7 DJ S6 H10 HJ DQ DK C10...

output:

36

result:

ok single line: '36'

Test #20:

score: 0
Accepted
time: 4ms
memory: 13672kb

input:

100 48 52
DJ C2 C9 CK C3 C9 S2 H4 H9 H7 S10 SK H7 C2 D9 C4 H4 S9 H4 H8 C9 HQ C6 S3 C10 H2 HQ D7 CQ SA C2 CQ C9 D10 D7 S6 H8 CJ C5 S9 CA D4 C3 C3 D6 S2 C6 H5 SA SJ S4 D8 C4 C3 CQ D5 C3 C9 S2 S9 C8 D10 S3 H8 S2 C4 H10 SA C6 D7 C6 H8 D6 H9 C7 HA S9 S9 D4 D2 SK D7 SJ D4 H4 C7 C5 CQ HK S8 SA HJ C3 C4 C6 ...

output:

35

result:

ok single line: '35'

Test #21:

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

input:

100 51 49
H7 SK SQ D5 CA C9 H8 C8 S7 SJ S2 H8 DJ SA H7 DK D2 H10 S7 D10 DQ CJ C3 SK H7 H6 H5 S2 H10 CQ S9 C4 HQ SJ D10 S7 C6 CJ H7 SQ S4 S8 H7 C9 D5 D3 C9 S8 C6 H5 HJ S7 S7 S2 C5 C3 C5 D8 D10 S10 CA D8 DQ SQ SJ HA CJ HK C8 HQ H6 D5 SJ DK DA C10 SQ C3 S3 SQ S6 CA D7 C6 D2 DJ C10 HA HQ S7 C7 C6 CQ C9 ...

output:

33

result:

ok single line: '33'

Test #22:

score: 0
Accepted
time: 2ms
memory: 15052kb

input:

100 55 45
HQ H5 D7 H7 C6 CQ CQ HK C5 C2 C2 CK S2 S7 S5 HK D5 HK C10 CJ D7 SK S7 S8 CA HA D9 DA S6 H5 H3 S7 C5 H3 D7 H8 H3 CJ SQ S6 H2 D5 DK S9 H3 S3 D8 C6 H7 DQ DQ H7 H10 S9 C9 H6 D7 S6 HJ HA D2 DQ C8 S7 C5 CK H8 HQ DQ S9 C6 C10 DQ D7 H2 HQ H5 D2 C2 DK CJ S7 H9 S7 S9 DJ D3 C7 HA S6 C8 HK S7 C6 CJ HQ...

output:

41

result:

ok single line: '41'

Test #23:

score: 0
Accepted
time: 6ms
memory: 16852kb

input:

100 64 36
SK CQ H10 C8 C4 D10 S2 C6 CA HK SA C3 C4 HJ HK C2 H4 D4 CA D8 S4 CJ S8 S6 H8 S5 C3 SA C2 S9 H6 S8 S7 C10 D6 D3 S2 C6 C10 S8 SK H2 CK H3 D7 C9 S7 SA D9 H8 D2 DA H6 DQ S8 D9 H5 C2 S7 D5 D7 HA D4 C3 H5 H2 D10 C5 HA H5 H6 D9 S10 C9 C2 S4 H5 D6 C6 CJ D9 D3 SA SA H6 CJ HQ H5 HK C3 D7 D4 H8 CJ C2...

output:

37

result:

ok single line: '37'

Test #24:

score: 0
Accepted
time: 52ms
memory: 104200kb

input:

300 167 133
CQ DK C10 CK S2 D5 CA SQ D4 D9 H9 D7 H4 SQ H7 CA CJ C3 D10 HA S8 CK HA SA D6 S2 S3 H6 SK D2 CK C10 D3 SK C7 C8 H5 C6 SJ C3 D7 D2 HQ S4 DA D3 H7 H5 S6 D3 D5 S3 SJ DJ S9 CQ SK HJ S3 DA S7 H10 CA H8 H10 S9 CJ H10 S5 CK C3 S9 DQ H4 HA SJ C2 C3 D7 CJ D10 CA D9 H7 H8 C10 CA SA C3 D5 H9 H5 S5 C...

output:

100

result:

ok single line: '100'

Test #25:

score: 0
Accepted
time: 48ms
memory: 108360kb

input:

300 174 126
CA S2 D8 D7 S6 D2 D10 S9 CK H4 SJ H7 C4 H6 C3 H6 HQ S6 S8 C4 C6 H6 D7 SK D7 S10 H6 H10 HA C3 H8 S8 D7 SA C8 C2 D6 C6 H2 C5 CA C2 S10 S6 S8 C4 S9 C6 D7 S5 S2 C7 D6 C7 S4 DQ C3 DA H2 CJ CQ HQ D8 S6 SJ S5 DK D8 CJ DQ CK D3 D4 H3 C6 S4 SA H9 CA D10 HA HA C4 S10 S8 D3 D9 SA SQ H3 S7 H4 S4 CQ ...

output:

101

result:

ok single line: '101'

Test #26:

score: 0
Accepted
time: 48ms
memory: 111396kb

input:

300 177 123
D5 S8 CQ HQ SQ D7 SA D8 D10 S6 CJ C3 S5 H7 DQ HQ D4 S8 DA S6 DK CJ DA H3 SA C10 H10 C6 C7 H6 C2 SA SA HQ C6 S3 S4 CA C9 D10 S4 H7 DQ HA C7 H9 C7 C5 S8 H2 HA H7 C9 S6 H8 C4 C10 S9 C10 C6 C4 S7 C7 SK C10 DA S2 D10 DQ H8 HK C8 S5 DA C10 D8 S2 S8 D10 SJ H6 D7 HA HA D6 H9 HQ D8 S3 H2 C3 D10 H...

output:

96

result:

ok single line: '96'

Test #27:

score: 0
Accepted
time: 50ms
memory: 114216kb

input:

300 184 116
HQ DA D4 C9 S4 DA CA H3 S5 CQ H5 DA C5 DK S10 C9 S5 HA S4 DK SA H7 D7 H9 S4 C5 D5 C10 SK D7 H3 H9 SQ HK C6 H10 H4 CA S10 D7 D8 DK H10 HJ D4 H10 D8 H6 D9 CA C3 S6 H7 HK H3 D5 DQ H7 S8 S7 C6 S6 H4 C3 DJ DK SJ SK H9 C10 HK H2 SJ D4 H5 CK S6 DQ SQ SA S7 C7 D6 SQ D10 S3 S7 D9 S2 HJ DQ D9 H5 C...

output:

99

result:

ok single line: '99'

Test #28:

score: 0
Accepted
time: 53ms
memory: 115992kb

input:

300 187 113
H3 D3 C9 CA SK D3 HK C7 D3 D2 S4 C7 S7 D8 CJ D4 S8 HJ C7 CQ S3 D7 DK HJ D8 C5 C9 H6 D3 S10 C10 HK DQ C7 C4 HA C2 C3 C4 DK CQ S4 C2 H5 H10 CA HK S10 H5 S8 SK H5 D10 DA H7 S8 D3 S5 C3 S8 C9 C4 D3 D9 H5 HQ D8 SQ H3 D4 CK D7 DQ DK S4 HA SA H8 DQ H9 CQ SA SJ H3 C4 C9 CJ SJ SK SK D2 S2 DA C5 H...

output:

98

result:

ok single line: '98'

Test #29:

score: 0
Accepted
time: 247ms
memory: 165468kb

input:

500 161 339
CJ S10 H9 C4 S10 CK H6 S7 C10 HA S8 S7 CK SQ S3 D7 D9 SK S5 S8 D10 CK DQ CJ H2 C6 SJ HA C3 H3 SQ C2 H5 CA CJ S5 D7 H5 C8 D2 C9 H8 C7 HJ HQ H6 DK D8 S5 H8 S10 D3 C3 S8 D6 HA HA DQ H5 S5 SJ DK SA SQ CA C7 S4 D7 CA H6 D10 H6 C2 C2 HK S5 D7 S8 CJ C7 D3 H6 C6 H9 H7 D4 D4 D9 H7 C4 HK SK DK SK ...

output:

161

result:

ok single line: '161'

Test #30:

score: 0
Accepted
time: 300ms
memory: 273904kb

input:

500 271 229
SQ C6 S8 C3 C3 HQ S10 S9 D6 HQ C6 H6 HA C7 HK D6 S8 HQ H8 SJ C10 CK C8 H2 DK D7 S3 H2 H2 C7 C8 SQ D6 C9 CQ HJ S7 C4 D4 CK SA CJ D2 S2 S3 HJ SQ S6 CQ HK C8 H4 HJ H8 S3 D8 H5 HK D2 CK H3 H7 H5 H7 DA S6 HJ SJ C2 HJ DQ CK H4 DK SA SK D9 S8 D5 C3 HQ C6 H10 D4 D5 SA S9 S3 S9 SQ CJ H2 S3 SQ D5 ...

output:

165

result:

ok single line: '165'

Test #31:

score: 0
Accepted
time: 226ms
memory: 370636kb

input:

500 369 131
S3 C10 D4 H8 HA SA C7 H8 HK H5 C6 C9 D2 H9 HK CJ C10 HA H2 D10 C4 S6 C3 D8 SA SA DK S8 CJ D2 HQ SK SA S8 HQ H2 HA S10 S4 S9 CQ C7 D2 H6 S2 HQ H2 DJ HJ C10 SQ H8 S4 D2 H2 H3 S2 SA HQ H2 C8 S7 H8 C7 H6 D8 HJ S5 HJ D8 D5 CK H6 H9 D10 H6 SK H5 HJ SQ H9 CQ S5 C7 CK D5 S9 DA H3 C10 H7 HJ H7 S2...

output:

163

result:

ok single line: '163'

Test #32:

score: 0
Accepted
time: 238ms
memory: 181256kb

input:

500 177 323
HJ S4 C10 C9 SK CQ HJ D9 H3 D2 S4 C3 H9 H4 C6 D5 DQ D8 D7 H8 D5 HK D2 CA CK C5 D2 C10 CK HJ C5 HQ CA SA CK D7 H6 H2 CK HQ SA H6 C3 CJ H6 SJ DJ H10 D3 C3 H7 D6 H5 CQ S8 H7 CJ D7 H10 H2 S3 S8 DK D4 CJ D5 H4 H9 H2 S3 S10 DK H6 S7 HQ CK C4 C5 H8 S10 S8 HQ C4 C3 D9 C2 S6 S8 DQ DK D8 S3 C4 SJ ...

output:

166

result:

ok single line: '166'

Test #33:

score: 0
Accepted
time: 259ms
memory: 191064kb

input:

500 187 313
C3 DJ C5 HA S10 C10 DQ S3 H10 SK H9 C7 H10 D10 CK S8 H5 CJ C8 S3 S10 SJ C3 C8 H9 CJ SQ H10 DK S5 DJ H2 S6 DK C10 C2 SJ H8 D8 H8 D8 C3 S8 S7 D2 D6 SJ D2 DJ D2 H8 C10 SQ D6 S7 DA DK H8 H3 C9 C8 C5 H8 SJ H8 S7 CA C9 C4 HK D6 HA C2 H8 DJ D7 S4 S5 HA D6 C4 C10 D6 C8 CK HQ D9 D5 C2 D9 H7 D8 SJ...

output:

159

result:

ok single line: '159'