这题卡常数?
查看原帖
这题卡常数?
820476
df1050楼主2024/5/17 14:28

C#字符串写的,然后TLE了三个点,感觉应该是卡常数了

代码:

// dotnet new console --langVersion 7.3
// fk msc.
// .csproj:
//<Project Sdk="Microsoft.NET.Sdk">
//
//  <PropertyGroup>
//    <OutputType>Exe</OutputType>
//    <TargetFramework>net8.0</TargetFramework>
//    <LangVersion>7.3</LangVersion>
//  </PropertyGroup>
//
//</Project>

using System;

namespace df1050
{
    class Program
    {
        static void Main(string[] args)
        {
            var len = Array.ConvertAll(Console.ReadLine().Trim().Split(' '), int.Parse);
            var code = new string[len[0]];
            for (int i = 0; i < len[0]; i++)
                code[i] = Console.ReadLine().Trim();
            for (; len[1] > 0; len[1]--)
            {
                int res = 0;
                var req = Console.ReadLine().Trim().Split(' ')[1];
                foreach (var i in code)
                    if (i.EndsWith(req))
                        res++;
                Console.WriteLine(res);
            }
        }
    }
}

2024/5/17 14:28
加载中...