提出 #72029579


ソースコード 拡げる

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

const ll N = 3e5 + 5, MOD = 998244353;

int get(char a, char b)
{
    if (a > b) b += 10;
    return b - a;
}

void sol()
{
    int n, m, res = 0x3f3f3f3f;
    string s, t;
    cin >> n >> m;
    cin >> s >> t;

    for (int i = 0; i <= n - m; ++i)
    {
        int cnt = 0;
        for (int j = 0; j < m; ++j)
        {
            cnt += get(t[j], s[i + j]);
        }
        res = min(res, cnt);
    }

    cout << res;
}

int main()
{
    int T = 1;
    // cin >> T;
    while (T--)
    {
        sol();
    }

    return 0;
}

提出情報

提出日時
問題 B - Substring 2
ユーザ altman_xie
言語 C++23 (GCC 15.2.0)
得点 200
コード長 643 Byte
結果 AC
実行時間 1 ms
メモリ 3604 KiB

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 200 / 200
結果
AC × 4
AC × 22
セット名 テストケース
Sample 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 00_sample_03.txt
All 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 00_sample_03.txt, 01_random_00.txt, 01_random_01.txt, 01_random_02.txt, 01_random_03.txt, 01_random_04.txt, 01_random_05.txt, 01_random_06.txt, 01_random_07.txt, 01_random_08.txt, 01_random_09.txt, 01_random_10.txt, 01_random_11.txt, 01_random_12.txt, 01_random_13.txt, 01_random_14.txt, 01_random_15.txt, 01_random_16.txt, 01_random_17.txt
ケース名 結果 実行時間 メモリ
00_sample_00.txt AC 1 ms 3544 KiB
00_sample_01.txt AC 1 ms 3440 KiB
00_sample_02.txt AC 1 ms 3380 KiB
00_sample_03.txt AC 1 ms 3592 KiB
01_random_00.txt AC 1 ms 3404 KiB
01_random_01.txt AC 1 ms 3544 KiB
01_random_02.txt AC 1 ms 3456 KiB
01_random_03.txt AC 1 ms 3556 KiB
01_random_04.txt AC 1 ms 3452 KiB
01_random_05.txt AC 1 ms 3564 KiB
01_random_06.txt AC 1 ms 3512 KiB
01_random_07.txt AC 1 ms 3584 KiB
01_random_08.txt AC 1 ms 3544 KiB
01_random_09.txt AC 1 ms 3584 KiB
01_random_10.txt AC 1 ms 3408 KiB
01_random_11.txt AC 1 ms 3604 KiB
01_random_12.txt AC 1 ms 3408 KiB
01_random_13.txt AC 1 ms 3544 KiB
01_random_14.txt AC 1 ms 3552 KiB
01_random_15.txt AC 1 ms 3564 KiB
01_random_16.txt AC 1 ms 3544 KiB
01_random_17.txt AC 1 ms 3564 KiB