QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#298513#7955. Tandem CopySolitaryDream#WA 0ms3612kbC++171.7kb2024-01-06 12:13:072024-01-06 12:13:07

Judging History

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

  • [2024-01-06 12:13:07]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3612kb
  • [2024-01-06 12:13:07]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
const int N = 2e4 + 10;;
string s, t;
int n, m, ans[N], f[2][N];
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cin >> s >> t;
    // s.resize(2e4);
    // t.resize(2e4);
    // for (int i = 1; i <= 2e4; ++i) s[i] = 'a' + (i & 1);
    // for (int i = 1; i <= 2e4; ++i) t[i] = 'a' + (i & 1);
    n = s.size(); m = t.size();
    s = ' ' + s; t = ' ' + t;
    {
        int tp = 0;
        for (int i = 1; i <= m; ++i) if (t[i] != t[i - 1]) t[++tp] = t[i];
        m = tp;
        t.resize(tp + 1);
    }
    ans[n + 1] = n + 1;
    if (m == 1) {
        for (int i = n; i; --i) {
            ans[i] = (s[i] == t[1] ? i : n + 1);
            ans[i] = min(ans[i], ans[i + 1]);
        }
    } else {
        for (int i = 1; i <= m + 1; ++i) f[n & 1][i] = n + 1;
        f[n & 1][m] = (s[n] == t[m] ? n : n + 1);
        ans[n] = n + 1; 
        for (int i = n - 1; i; --i) {
            f[i & 1][m + 1] = i;
            f[i & 1][m] = (s[i] == t[m] ? i : n + 1);
            if (s[i + 1] == t[m]) f[i & 1][m] = i + 1;
            for (int j = m - 1; j; --j) {
                if (s[i] != t[j]) f[i & 1][j] = n + 1;
                else {
                    f[i & 1][j] = f[(i + 1) & 1][j + 1];
                    if (s[i + 1] == t[j + 1]) f[i & 1][j] = min(f[i & 1][j], max(i + 1, f[i & 1][j + 2]));
                }
            }
            ans[i] = min(f[i & 1][1], ans[i + 1]);
            if (s[i + 1] == t[1]) ans[i] = min(ans[i], max(i + 1, f[i & 1][2]));
        }
    }
    int rst = 0;
    for (int i = 1; i <= n; ++i) rst += n - ans[i] + 1;
    cout << rst << endl;
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

ACGCG
CCG

output:

9

result:

ok single line: '9'

Test #2:

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

input:

TATCGC
TTCCG

output:

6

result:

ok single line: '6'

Test #3:

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

input:

ABCABC
ABC

output:

7

result:

ok single line: '7'

Test #4:

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

input:

ABCABC
ABCABC

output:

1

result:

ok single line: '1'

Test #5:

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

input:

FUSBX
UUUUUUUUUU

output:

8

result:

ok single line: '8'

Test #6:

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

input:

IWN
NNNNNNNNNN

output:

3

result:

ok single line: '3'

Test #7:

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

input:

RMRMRMRMRMRMRMRMRMRMR
MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMR

output:

210

result:

ok single line: '210'

Test #8:

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

input:

TY
YT

output:

1

result:

ok single line: '1'

Test #9:

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

input:

WZ
ZW

output:

1

result:

ok single line: '1'

Test #10:

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

input:

SBSBSBSBSBSBSBSBSBSBSBSBSBSBSBSBSBSBWGVXPWAXMSBSB
SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS...

output:

1121

result:

ok single line: '1121'

Test #11:

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

input:

TGJPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPX
PPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPP...

output:

897

result:

ok single line: '897'

Test #12:

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

input:

MKZOLDYLGAULULULUGASEAOZVIHNMRGKZQEIQYTGEMLBMAULULULULULULULPNERGKYZARPULULULULULAOZLQGYHULULULULZKYZUXEBVXZBULULULULULULULULULULULULULULULULDCEXCSTHQRULULULULULULULULULULULULULULULULULRDMPBDULULULUFVXWEMTULULULULULULULULULULULULULULULULULULULULCLULULULULULULULULULULULULULULULULULULULULULULULULULULU...

output:

46504894

result:

wrong answer 1st lines differ - expected: '46504613', found: '46504894'