Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- namespace Wormhole
- {
- public class Wormhole
- {
- public static void Main()
- {
- var input = Console.ReadLine();
- var wormholes = input
- .Split(new[] { ' '}, StringSplitOptions.RemoveEmptyEntries)
- .Select(int.Parse)
- .ToArray();
- var counter = 0;
- for (int i = 0; i < wormholes.Length; i++)
- {
- if (wormholes[i] == 0)
- {
- counter++;
- }
- else
- {
- var realI = i;
- i = (wormholes[i]-1);
- wormholes[realI] = 0;
- // counter++;
- }
- }
- Console.WriteLine(counter);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement