ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1563. Bayan

C# Please, Help! Where is wrong?
Posted by Serge 12 Jan 2018 05:28
The answer is correct, but it returns an error. Why? Maybe I did not understand the condition of the task correctly, or can the data be specified for which this code will produce the wrong solution?


using System;

namespace ConsoleApp30
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int x = 0;
            string[] shoplist = new string[n];
            for (int i = 0; i <n; i++)
            {
                shoplist[i] = Console.ReadLine();
            }

            for (int i = 0; i < shoplist.Length; i++)
            {
                for (int j = i + 1; j<shoplist.Length; j++)
                {
                    if (shoplist[i] == shoplist[j])
                    {
                        x++;
                        i++;
                    }
                    else
                    {
                        continue;
                    }
                }
            }

            Console.WriteLine(x);
            //Console.ReadKey();
        }
    }
}