QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#532686 | #5087. Shuffle Game | BongoCatEnjoyer# | WA | 0ms | 3884kb | C++14 | 1.4kb | 2024-08-25 09:26:18 | 2024-08-25 09:26:18 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define forn(i, n) for (ll i = 0; i < n; ++i)
#define forr(i, s, n) for (ll i = s; i < n; ++i)
#define fori(i, s, n) for (ll i = s; i > n; --i)
#define fora(i, n) for (auto i: n)
#define vi vector<int>
#define vll vector<ll>
const int MOD = 998244353;
// const int MOD = 1e9 + 7;
int lcs(vector<int>& a, vector<int>& b) {
int n = a.size(), m = b.size();
vector<vector<int>> dp(n + 1, vector<int>(m + 1));
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= m; j++) {
if (a[i - 1] == b[j - 1]) {
dp[i][j] = 1 + dp[i - 1][j - 1];
} else {
dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
}
}
}
return dp[n][m];
}
void solve() {
int n, m, k;
cin >> n >> m >> k;
vi a(n), b(m), c(k);
forn(i, n) {
string s;
cin >> s;
a[i] = (int)s[0] * 256 + s[1];
}
forn(i, m) {
string s;
cin >> s;
b[i] = (int)s[0] * 256 + s[1];
}
forn(i, k) {
string s;
cin >> s;
c[i] = (int)s[0] * 256 + s[1];
}
cout << lcs(a, b) + lcs(a, c) << endl;
}
int32_t main() {
ios::sync_with_stdio(false);
cin.tie(NULL);
int t = 1;
// cin >> t;
while (t--) solve();
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3556kb
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: 3556kb
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: 3556kb
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: 3820kb
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: 3852kb
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: 3784kb
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: 3556kb
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: 3552kb
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: 3628kb
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: 0ms
memory: 3560kb
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: 3620kb
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: 0ms
memory: 3592kb
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: 3788kb
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: 0ms
memory: 3652kb
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: 0ms
memory: 3580kb
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: 3836kb
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: 0ms
memory: 3884kb
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: 0ms
memory: 3636kb
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: -100
Wrong Answer
time: 0ms
memory: 3676kb
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:
37
result:
wrong answer 1st lines differ - expected: '36', found: '37'