QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#709360 | #5087. Shuffle Game | OOBMABTRAMS# | WA | 0ms | 3816kb | C++17 | 961b | 2024-11-04 14:19:48 | 2024-11-04 14:19:48 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=503;
int dp[N][N];
int hs(string s) {
return s[0]*200+s[1];
}
int a[N],b[N],c[N];
int main(){
int n,x,y;
cin>>n>>x>>y;
for(int i=1;i<=n;i++) {
string s;
cin>>s;
a[i]=hs(s);
}
for(int i=1;i<=x;i++) {
string s;
cin>>s;
b[i]=hs(s);
}
for(int i=1;i<=y;i++) {
string s;
cin>>s;
c[i]=hs(s);
}
for(int i=1;i<=n;i++) {
for(int j=x;~j;j--)for(int k=y;~k;k--) {
if(j)dp[j][k]=max(dp[j-1][k]+(a[i]==b[j]),dp[j][k]);
if(k)dp[j][k]=max(dp[j][k-1]+(a[i]==c[k]),dp[j][k]);
}
int mx=0;
for(int j=0;j<=x;j++)for(int k=0;k<=y;k++) {
mx=max(mx,dp[j][k]);
}
}
int ans=0;
for(int i=1;i<=n;i++)for(int j=1;j<=n;j++)ans=max(ans,dp[i][j]);
cout<<ans<<'\n';
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3580kb
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: 3588kb
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: 3584kb
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: 3816kb
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: 3804kb
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: 3736kb
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: 3588kb
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: 3620kb
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: 3596kb
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: 3572kb
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'