Quantcast
Channel: CodeChef Discuss - latest questions
Viewing all articles
Browse latest Browse all 39796

Always getting NZEC Error

$
0
0

This is my code c# code,

using System; using System.Collections.Generic; using System.Text; using System.Text.RegularExpressions;

namespace Playlist { class Program { static int n,m,cnt=0,key=-1; static string pattern;
static List<string> songs = new List<string>(); static List<keyvaluepair<string, int="">> list = new List<keyvaluepair<string, int="">>();

    static int Main(string[] args)
    {
        string ip = Console.ReadLine();
        int t = Convert.ToInt32(ip);

        for (int i = 0; i < t; i++)
        {
            string ip1 = Console.ReadLine();
            string[] ipa1 = ip1.Split(' ');

            n = Convert.ToInt32(ipa1[0]);
            pattern = ipa1[1];
            m = Convert.ToInt32(ipa1[2]);

            for (int j = 0; j < n; j++)
            {                    
                songs.Add(Console.ReadLine());

                string re = pattern;
                re = re.Replace("_", ".");
                re = re.Replace("%", ".*?");
                MatchCollection mc= Regex.Matches( songs[songs.Count - 1] ,re);

                if (mc.Count >= m)
                {
                    list.Add(new KeyValuePair<string, int>(songs[songs.Count - 1], i));
                    cnt++;
                }
            }
        }

        foreach (KeyValuePair<string, int> kvp in list)
        {

            if (key != kvp.Value)
            {
                Console.WriteLine("Case: {0}", kvp.Value + 1);
                Console.WriteLine(kvp.Key);
                key = kvp.Value;
            }
            else
                Console.WriteLine(kvp.Key);
        }

        Console.Read();
        return 0;
    }
}

}

Can you please tell me why I am getting NZEC error?


Viewing all articles
Browse latest Browse all 39796

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>