Submission #46539612


Source Code Expand

using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Numerics;

namespace Tasks;

public class C
{
    public static void Main()
    {
        using var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
        Console.SetOut(sw);
        Solve();
        Console.Out.Flush();
    }

    public static void Solve()
    {
        var (N, T) = Scanner.Scan<int, string>();
        var answers = new List<int>();
        const int Inf = 1 << 30;
        for (var i = 0; i < N; i++)
        {
            var S = Scanner.Scan<string>();
            if (S == T)
            {
                answers.Add(i + 1);
                continue;
            }

            if (Math.Abs(S.Length - T.Length) > 1) continue;
            var si = 0;
            var ti = 0;
            var diff = 0;
            var ok = true;
            while (si < S.Length && ti < T.Length && ok)
            {
                if (S[si] == T[ti])
                {
                    si++;
                    ti++;
                }
                else
                {
                    if (diff < 1)
                    {
                        diff++;
                        if (S.Length < T.Length) ti++;
                        else if (T.Length < S.Length) si++;
                        else { si++; ti++; }
                    }
                    else
                    {
                        ok = false;
                    }
                }
            }

            if (ok) answers.Add(i + 1);
        }

        Console.WriteLine(answers.Count);
        if (answers.Count == 0) Console.WriteLine();
        else Console.WriteLine(string.Join(" ", answers));
    }

    public static class Scanner
    {
        public static T Scan<T>() where T : IConvertible => Convert<T>(ScanStringArray()[0]);
        public static (T1, T2) Scan<T1, T2>() where T1 : IConvertible where T2 : IConvertible
        {
            var input = ScanStringArray();
            return (Convert<T1>(input[0]), Convert<T2>(input[1]));
        }
        public static (T1, T2, T3) Scan<T1, T2, T3>() where T1 : IConvertible where T2 : IConvertible where T3 : IConvertible
        {
            var input = ScanStringArray();
            return (Convert<T1>(input[0]), Convert<T2>(input[1]), Convert<T3>(input[2]));
        }
        public static (T1, T2, T3, T4) Scan<T1, T2, T3, T4>() where T1 : IConvertible where T2 : IConvertible where T3 : IConvertible where T4 : IConvertible
        {
            var input = ScanStringArray();
            return (Convert<T1>(input[0]), Convert<T2>(input[1]), Convert<T3>(input[2]), Convert<T4>(input[3]));
        }
        public static (T1, T2, T3, T4, T5) Scan<T1, T2, T3, T4, T5>() where T1 : IConvertible where T2 : IConvertible where T3 : IConvertible where T4 : IConvertible where T5 : IConvertible
        {
            var input = ScanStringArray();
            return (Convert<T1>(input[0]), Convert<T2>(input[1]), Convert<T3>(input[2]), Convert<T4>(input[3]), Convert<T5>(input[4]));
        }
        public static (T1, T2, T3, T4, T5, T6) Scan<T1, T2, T3, T4, T5, T6>() where T1 : IConvertible where T2 : IConvertible where T3 : IConvertible where T4 : IConvertible where T5 : IConvertible where T6 : IConvertible
        {
            var input = ScanStringArray();
            return (Convert<T1>(input[0]), Convert<T2>(input[1]), Convert<T3>(input[2]), Convert<T4>(input[3]), Convert<T5>(input[4]), Convert<T6>(input[5]));
        }
        public static IEnumerable<T> ScanEnumerable<T>() where T : IConvertible => ScanStringArray().Select(Convert<T>);
        private static string[] ScanStringArray()
        {
            var line = Console.ReadLine()?.Trim() ?? string.Empty;
            return string.IsNullOrEmpty(line) ? Array.Empty<string>() : line.Split(' ');
        }
        private static T Convert<T>(string value) where T : IConvertible => (T)System.Convert.ChangeType(value, typeof(T));
    }
}

Submission Info

Submission Time
Task C - Error Correction
User AconCavy
Language C# 11.0 (.NET 7.0.7)
Score 300
Code Size 4146 Byte
Status AC
Exec Time 126 ms
Memory 63544 KiB

Compile Error

/judge/Main.cs(24,19): warning CS0219: The variable 'Inf' is assigned but its value is never used [/judge/Main.csproj]

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 300 / 300
Status
AC × 3
AC × 32
Set Name Test Cases
Sample example0.txt, example1.txt, example2.txt
All 000.txt, 001.txt, 002.txt, 003.txt, 004.txt, 005.txt, 006.txt, 007.txt, 008.txt, 009.txt, 010.txt, 011.txt, 012.txt, 013.txt, 014.txt, 015.txt, 016.txt, 017.txt, 018.txt, 019.txt, 020.txt, 021.txt, 022.txt, 023.txt, 024.txt, 025.txt, 026.txt, 027.txt, 028.txt, example0.txt, example1.txt, example2.txt
Case Name Status Exec Time Memory
000.txt AC 40 ms 26440 KiB
001.txt AC 46 ms 30168 KiB
002.txt AC 38 ms 30000 KiB
003.txt AC 50 ms 30008 KiB
004.txt AC 46 ms 30012 KiB
005.txt AC 46 ms 30016 KiB
006.txt AC 126 ms 63544 KiB
007.txt AC 103 ms 51900 KiB
008.txt AC 76 ms 39420 KiB
009.txt AC 57 ms 32784 KiB
010.txt AC 56 ms 29688 KiB
011.txt AC 48 ms 28120 KiB
012.txt AC 51 ms 27256 KiB
013.txt AC 45 ms 26628 KiB
014.txt AC 49 ms 26580 KiB
015.txt AC 46 ms 26636 KiB
016.txt AC 49 ms 26716 KiB
017.txt AC 50 ms 27044 KiB
018.txt AC 37 ms 27572 KiB
019.txt AC 43 ms 27208 KiB
020.txt AC 41 ms 27840 KiB
021.txt AC 41 ms 27792 KiB
022.txt AC 47 ms 27372 KiB
023.txt AC 37 ms 27524 KiB
024.txt AC 36 ms 27660 KiB
025.txt AC 45 ms 29924 KiB
026.txt AC 102 ms 55208 KiB
027.txt AC 103 ms 55072 KiB
028.txt AC 97 ms 55360 KiB
example0.txt AC 42 ms 25228 KiB
example1.txt AC 47 ms 25224 KiB
example2.txt AC 36 ms 25264 KiB