Submission #7041951


Source Code Expand

using System;
using System.Collections.Generic;
using static System.Console;

class Program
{
    public static void Main()
    {
        int N = 'z'-'a'+1;

        string s = ReadLine();
        string t = ReadLine();
        string ss = s + s;

        int [,] lut = new int[s.Length, N];
        for (char c = 'a'; c <= 'z'; c++)
        {
            int j = 0;
            for (int i = ss.Length - 1; i >= 0; i--)
            {
                if (ss[i] == c)
                {
                    j = 1;
                }
                else
                {
                    if (j > 0){ j++; }
                }
                if (i < s.Length){ lut[i, c-'a'] = j; }
            }
        }

        long ct = 0;
        for(int i = 0; i < t.Length; i++)
        {
            char c = t[i];
            int k = lut[ct % s.Length, c-'a'];
            if (k == 0){ WriteLine(-1); return; }
            ct += k;
        }
        WriteLine(ct);
    }
}

Submission Info

Submission Time
Task E - Strings of Impurity
User unnohideyuki
Language C# (Mono 4.6.2.0)
Score 500
Code Size 1006 Byte
Status AC
Exec Time 42 ms
Memory 22240 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 500 / 500
Status
AC × 3
AC × 45
Set Name Test Cases
Sample a01, a02, a03
All a01, a02, a03, b04, b05, b06, b07, b08, b09, b10, b11, b12, b13, b14, b15, b16, b17, b18, b19, b20, b21, b22, b23, b24, b25, b26, b27, b28, b29, b30, b31, b32, b33, b34, b35, b36, b37, b38, b39, b40, b41, b42, b43, b44, b45
Case Name Status Exec Time Memory
a01 AC 20 ms 9044 KiB
a02 AC 20 ms 9044 KiB
a03 AC 20 ms 9044 KiB
b04 AC 20 ms 9044 KiB
b05 AC 20 ms 9044 KiB
b06 AC 20 ms 11092 KiB
b07 AC 20 ms 9044 KiB
b08 AC 20 ms 11092 KiB
b09 AC 20 ms 9172 KiB
b10 AC 39 ms 20192 KiB
b11 AC 39 ms 20192 KiB
b12 AC 39 ms 20192 KiB
b13 AC 39 ms 22240 KiB
b14 AC 39 ms 22240 KiB
b15 AC 39 ms 22240 KiB
b16 AC 39 ms 20192 KiB
b17 AC 42 ms 20192 KiB
b18 AC 42 ms 20192 KiB
b19 AC 42 ms 20192 KiB
b20 AC 40 ms 20192 KiB
b21 AC 40 ms 22240 KiB
b22 AC 41 ms 22240 KiB
b23 AC 40 ms 20192 KiB
b24 AC 41 ms 22240 KiB
b25 AC 41 ms 22240 KiB
b26 AC 41 ms 20192 KiB
b27 AC 41 ms 22240 KiB
b28 AC 40 ms 20192 KiB
b29 AC 41 ms 20192 KiB
b30 AC 41 ms 20192 KiB
b31 AC 38 ms 22240 KiB
b32 AC 22 ms 9184 KiB
b33 AC 22 ms 11232 KiB
b34 AC 36 ms 19808 KiB
b35 AC 37 ms 19808 KiB
b36 AC 39 ms 20192 KiB
b37 AC 39 ms 22240 KiB
b38 AC 39 ms 22240 KiB
b39 AC 39 ms 20192 KiB
b40 AC 38 ms 20192 KiB
b41 AC 39 ms 22240 KiB
b42 AC 37 ms 22240 KiB
b43 AC 38 ms 22240 KiB
b44 AC 39 ms 22240 KiB
b45 AC 39 ms 22240 KiB