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 1837. Isenbaev's Number

что-то не так... на 4-том тесте ошибка
Posted by Conserj 22 Dec 2011 00:46
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections;

namespace ConsoleApplication1
{
classProgram
    {
staticvoid Main(string[] args)
        {
string Name = "Isenbaev";
ArrayList OF = newArrayList();
ArrayList NF = newArrayList();
int n = int.Parse(Console.ReadLine());
int[,] kol = newint[n, 3];
bool f = false;
string[,] name = newstring[n, 3];
for (int i = 0; i < n; i++)
            {
string[] s = Console.ReadLine().Split(' ');
for (int j = 0; j < 3; j++)
                {
                        f = true;
                        kol[i, j] = -1;
                        name[i, j] = s[j];

                }
            }
int t=1;
            OF.Add(Name);
while (OF.Count != 0)
            {
for (int z = 0; z < OF.Count; z++)
                {
                    r = false;
for (int i = 0; i < n; i++)
                    {
                        f = false;
for (int j = 0; j < 3; j++)
                        {
if ((OF[z].ToString().CompareTo(name[i, j]) == 0) && (kol[i, j] == -1))
                            {
                                kol[i, j] = t - 1;
                                f = true;
break;
                            }
                        }
if (f)
                        {
for (int j = 0; j < 3; j++)
                            {
if (OF[0].ToString().CompareTo(name[i, j]) != 0)
                                {
int d=0;

for (int y = 0; y < OF.Count; y++)
                                    {
if (name[i, j].CompareTo(OF[y].ToString()) == 0)
                                        {
                                            d++;
                                        }
                                    }
if (d == 0)
                                    {
                                        kol[i, j] = t;
                                    }
                                        NF.Add(name[i, j]);
}
                            }
                        }
                    }
                }
                OF.Clear();
for (int i = 0; i < NF.Count; i++)
{
                    OF.Add(NF[i]);
                }
                NF.Clear();
                t++;
            }
string[] res = newstring[n*3];
int k=0;
for (int i = 0; i < n; i++)
            {
for (int j = 0; j < 3; j++)
                {
if (kol[i, j] == -1)
                    {
                        res[k] = name[i, j] + " undefined";
                    }
else
                    {
                        res[k] = name[i, j] + " " + kol[i, j];
                    }
                        k++;
                }
            }
Array.Sort(res);
for (int i = 0; i < (n*3)-1; i++)
            {
if (res[i].CompareTo(res[i + 1]) != 0)
                {
Console.WriteLine(res[i]);
                }
            }
if ((res[n * 3 - 1]).CompareTo(res[n * 3 - 2]) != 0)
            {
Console.WriteLine(res[n*3-1]);
            }
        }
    }
}
Re: что-то не так... на 4-том тесте ошибка
Posted by Hikmat Ahmedov 27 Jan 2012 10:43
Your program is not reading 3rd name.
use
Console.ReadLine().Split(new char[] { ' ', '\t', '\n', '\r' }, StringSplitOptions.RemoveEmptyEntries);
istead of
Console.ReadLine().Split(' ');