Rezultati

Up. imeNalogaJezikRezultatČas oddaje
kira Prijateljske besede C# 0/100Napaka med izvajanjem / ob izhodu (RTE) 20. apr '17 @ 19:27

Test Točke Porabljen spomin Porabljen čas Status
#1 0/12 20,762 MiB 0,000 s Program je končal z neničelno kodo
Stderr:
Unhandled Exception:
System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
  at System.ThrowHelper.ThrowArgumentOutOfRangeException () <0x7f9ecacadd00 + 0x00034> in <filename unknown>:0 
  at System.Collections.Generic.List`1[T].get_Item (Int32 index) <0x7f9ecab3b0d0 + 0x0001e> in <filename unknown>:0 
  at PrijateljskeBesede.Program.Main (System.String[] args) <0x404b8fe0 + 0x0042e> in <filename unknown>:0 
[ERROR] FATAL UNHANDLED EXCEPTION: System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
  at System.ThrowHelper.ThrowArgumentOutOfRangeException () <0x7f9ecacadd00 + 0x00034> in <filename unknown>:0 
  at System.Collections.Generic.List`1[T].get_Item (Int32 index) <0x7f9ecab3b0d0 + 0x0001e> in <filename unknown>:0 
  at PrijateljskeBesede.Program.Main (System.String[] args) <0x404b8fe0 + 0x0042e> in <filename unknown>:0 
#2 0/12 20,809 MiB 0,000 s Program je končal z neničelno kodo
Stderr:
Unhandled Exception:
System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
  at System.ThrowHelper.ThrowArgumentOutOfRangeException () <0x7ff6180add00 + 0x00034> in <filename unknown>:0 
  at System.Collections.Generic.List`1[T].get_Item (Int32 index) <0x7ff617f3b0d0 + 0x0001e> in <filename unknown>:0 
  at PrijateljskeBesede.Program.Main (System.String[] args) <0x41ffafe0 + 0x0042e> in <filename unknown>:0 
[ERROR] FATAL UNHANDLED EXCEPTION: System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
  at System.ThrowHelper.ThrowArgumentOutOfRangeException () <0x7ff6180add00 + 0x00034> in <filename unknown>:0 
  at System.Collections.Generic.List`1[T].get_Item (Int32 index) <0x7ff617f3b0d0 + 0x0001e> in <filename unknown>:0 
  at PrijateljskeBesede.Program.Main (System.String[] args) <0x41ffafe0 + 0x0042e> in <filename unknown>:0 
#3 0/12 20,844 MiB 0,000 s Program je končal z neničelno kodo
Stderr:
Unhandled Exception:
System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
  at System.ThrowHelper.ThrowArgumentOutOfRangeException () <0x7f36ed8add00 + 0x00034> in <filename unknown>:0 
  at System.Collections.Generic.List`1[T].get_Item (Int32 index) <0x7f36ed73b0d0 + 0x0001e> in <filename unknown>:0 
  at PrijateljskeBesede.Program.Main (System.String[] args) <0x407aefe0 + 0x0042e> in <filename unknown>:0 
[ERROR] FATAL UNHANDLED EXCEPTION: System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
  at System.ThrowHelper.ThrowArgumentOutOfRangeException () <0x7f36ed8add00 + 0x00034> in <filename unknown>:0 
  at System.Collections.Generic.List`1[T].get_Item (Int32 index) <0x7f36ed73b0d0 + 0x0001e> in <filename unknown>:0 
  at PrijateljskeBesede.Program.Main (System.String[] args) <0x407aefe0 + 0x0042e> in <filename unknown>:0 
#4 0/12 20,840 MiB 0,000 s Program je končal z neničelno kodo
Stderr:
Unhandled Exception:
System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
  at System.ThrowHelper.ThrowArgumentOutOfRangeException () <0x7f77464add00 + 0x00034> in <filename unknown>:0 
  at System.Collections.Generic.List`1[T].get_Item (Int32 index) <0x7f774633b0d0 + 0x0001e> in <filename unknown>:0 
  at PrijateljskeBesede.Program.Main (System.String[] args) <0x4189efe0 + 0x0042e> in <filename unknown>:0 
[ERROR] FATAL UNHANDLED EXCEPTION: System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
  at System.ThrowHelper.ThrowArgumentOutOfRangeException () <0x7f77464add00 + 0x00034> in <filename unknown>:0 
  at System.Collections.Generic.List`1[T].get_Item (Int32 index) <0x7f774633b0d0 + 0x0001e> in <filename unknown>:0 
  at PrijateljskeBesede.Program.Main (System.String[] args) <0x4189efe0 + 0x0042e> in <filename unknown>:0 
#5 13/13 21,105 MiB 0,000 s OK
#6 0/13 21,121 MiB 0,000 s Napačen odgovor
Tvoj izhod:
​3<<<EOF>>>
Pravilen izhod:
​819
<<<EOF>>>
#7 0/13 18,914 MiB 0,156 s Program je končal z neničelno kodo
Stderr:
Unhandled Exception:
System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
  at System.ThrowHelper.ThrowArgumentOutOfRangeException () <0x7f6fcdcadd00 + 0x00034> in <filename unknown>:0 
  at System.Collections.Generic.List`1[T].get_Item (Int32 index) <0x7f6fcdb3b0d0 + 0x0001e> in <filename unknown>:0 
  at PrijateljskeBesede.Program.Main (System.String[] args) <0x4184efe0 + 0x0042e> in <filename unknown>:0 
[ERROR] FATAL UNHANDLED EXCEPTION: System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
  at System.ThrowHelper.ThrowArgumentOutOfRangeException () <0x7f6fcdcadd00 + 0x00034> in <filename unknown>:0 
  at System.Collections.Generic.List`1[T].get_Item (Int32 index) <0x7f6fcdb3b0d0 + 0x0001e> in <filename unknown>:0 
  at PrijateljskeBesede.Program.Main (System.String[] args) <0x4184efe0 + 0x0042e> in <filename unknown>:0 
#8 0/13 20,844 MiB 0,000 s Program je končal z neničelno kodo
Stderr:
Unhandled Exception:
System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
  at System.ThrowHelper.ThrowArgumentOutOfRangeException () <0x7fa109cadd00 + 0x00034> in <filename unknown>:0 
  at System.Collections.Generic.List`1[T].get_Item (Int32 index) <0x7fa109b3b0d0 + 0x0001e> in <filename unknown>:0 
  at PrijateljskeBesede.Program.Main (System.String[] args) <0x41170fe0 + 0x0042e> in <filename unknown>:0 
[ERROR] FATAL UNHANDLED EXCEPTION: System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
  at System.ThrowHelper.ThrowArgumentOutOfRangeException () <0x7fa109cadd00 + 0x00034> in <filename unknown>:0 
  at System.Collections.Generic.List`1[T].get_Item (Int32 index) <0x7fa109b3b0d0 + 0x0001e> in <filename unknown>:0 
  at PrijateljskeBesede.Program.Main (System.String[] args) <0x41170fe0 + 0x0042e> in <filename unknown>:0 

Ocenjevani program (Program.cs):
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace PrijateljskeBesede
{
    class Program
    {
        public class Skupina {
            public List<string> prefix;
            public List<string> postfix;
            public int stBesed;

            public Skupina(string pre, string post) {
                prefix = new List<string>();
                prefix.Add(pre);
                postfix = new List<string>();
                postfix.Add(post);
                stBesed = 1;
            }

            public void dodajPrefix(string pre)
            {
                prefix.Add(pre);
                stBesed++;
            }

            public void dodajPostfix(string post)
            {
                postfix.Add(post);
                stBesed++;
            }

            public static void mergeGroups(int a, int b, ref List<Skupina> skup)
            {
                skup[a].prefix.AddRange(skup[b].prefix);
                skup[a].postfix.AddRange(skup[b].postfix);
                skup[a].stBesed += skup[b].stBesed + 1;
                skup.RemoveAt(b);
                //mogoce morem prazna polja odstranit
            }

        }

        

        static void Main(string[] args)
        {

            //branje besed
            List<string> besede = new List<string>();
            int counter = Int32.Parse(Console.ReadLine());
            for(int i =0;i< counter; i++)
            {
                string tmp = Console.ReadLine();
                besede.Add(tmp);
            }


            //glavni algoritem
            List<Skupina> skup = new List<Skupina>();
            int indSkup = 0;
            for(int i = besede.Count - 1; i >= 0; i--)
            {
                string prefix = besede[i].Substring(0, 3);
                string postfix = besede[i].Substring(besede[i].Length-3, 3);

                indSkup = -1;
                bool isprefix = false;
                for(int j=0; j < skup.Count; j++)
                {
                    if( skup[j].prefix.Contains(prefix)){
                        if (indSkup != -1)
                        {
                            Skupina.mergeGroups(indSkup, j, ref skup);
                            indSkup = -2;
                            break;
                        }
                        indSkup = j;
                        isprefix = true;
                    }
                    if (skup[j].postfix.Contains(postfix))
                    {
                        if (indSkup != -1)
                        {
                            Skupina.mergeGroups(indSkup, j, ref skup);
                            indSkup = -2;
                            break;
                        }
                        indSkup = j;
                        isprefix = false;
                    }
                }

                if (indSkup == -1)
                {
                    Skupina nova = new Skupina(prefix, postfix);
                    skup.Add(nova);
                }
                else if (indSkup == -2) { continue; }
                else if (isprefix)
                {
                    skup[indSkup].postfix.Add(postfix);
                    skup[indSkup].stBesed++;
                }
                else
                {
                    skup[indSkup].prefix.Add(prefix);
                    skup[indSkup].stBesed++;
                }

            }
            Console.Write(skup[indSkup].stBesed);
        }
    }
}