Rezultati

Up. imeNalogaJezikRezultatČas oddaje
RipUA Jungle Speed C# 100/100OK 11. maj '17 @ 17:08

Test Točke Porabljen spomin Porabljen čas Status
#1 9/9 21,480 MiB 0,000 s OK
#2 9/9 21,473 MiB 0,000 s OK
#3 9/9 21,266 MiB 0,000 s OK
#4 9/9 21,465 MiB 0,000 s OK
#5 9/9 19,469 MiB 0,000 s OK
#6 9/9 19,473 MiB 0,000 s OK
#7 9/9 19,438 MiB 0,000 s OK
#8 9/9 19,508 MiB 0,000 s OK
#9 9/9 21,500 MiB 0,000 s OK
#10 9/9 21,473 MiB 0,000 s OK
#11 10/10 19,496 MiB 0,000 s OK

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

namespace PutkaJungleSpeed
{
    class Program
    {
        public class Player
        {
            public Player()
            {
                CardsHand = new List<int>();
                CardsTable = new List<int>();
            }

            public List<int> CardsHand;
            public List<int> CardsTable;

        }

        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            Player[] players = new Player[n];
            for (int i = 0; i < n; i++)
            {
                players[i] = new Player();
            }
                string cardsS = Console.ReadLine();
            string[] cards = cardsS.Split(' ');

            int currentPlayer = 0;
            for(int i = 0; i < cards.Length; i++)
            {
                players[currentPlayer].CardsHand.Add(int.Parse(cards[i]));
                currentPlayer = (currentPlayer + 1) % n;
            }

            currentPlayer = 0;
            while (true)
            {
            again:;
                if (players[currentPlayer].CardsHand.Count == 0)
                {
                    players[currentPlayer].CardsTable.Reverse();
                    players[currentPlayer].CardsHand.AddRange(players[currentPlayer].CardsTable);
                    players[currentPlayer].CardsTable.Clear();
                }
                int card = players[currentPlayer].CardsHand.Last();
                players[currentPlayer].CardsHand.RemoveAt(players[currentPlayer].CardsHand.Count - 1);
                players[currentPlayer].CardsTable.Add(card);

                for(int i = 0; i < n; i++)
                {
                    if (i == currentPlayer) continue;
                    if (players[i].CardsTable.Count > 0 && players[i].CardsTable.Last() == card)
                    {
                        players[i].CardsTable.AddRange(players[currentPlayer].CardsTable);
                        players[currentPlayer].CardsTable.Clear();
                        players[i].CardsTable.Reverse();
                        players[i].CardsTable.AddRange(players[currentPlayer].CardsHand);
                        players[currentPlayer].CardsHand.Clear();
                        List<int> temp = players[currentPlayer].CardsHand;
                        players[currentPlayer].CardsHand = players[i].CardsTable;
                        players[i].CardsTable = temp;
                        if (players[i].CardsHand.Count == 0)
                        {
                            Console.WriteLine(i + 1);
                            return;
                        }
                        goto again;
                    }
                }
                currentPlayer = (currentPlayer + 1) % n;
            }
        }
    }
}