fork download
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Diagnostics;
  4. using System.Threading;
  5. using System.Threading.Tasks;
  6.  
  7. namespace Spiner
  8. {
  9. public class Spiner
  10. {
  11. public int X { get; set; }
  12. public int Y { get; set; }
  13. private static object _locker = new object();
  14.  
  15. private char[] frames = { '\\', '|', '/', '-' };
  16. private int _currentFrame;
  17. public bool IsComplite { get; set; }
  18. public async void Run()
  19. {
  20. while (!IsComplite)
  21. {
  22. lock (_locker)
  23. {
  24. Console.CursorVisible = false;
  25. Console.SetCursorPosition(X, Y);
  26. Console.Write(frames[_currentFrame]);
  27. Console.CursorVisible = true;
  28. }
  29. await Task.Delay(500);
  30. _currentFrame++;
  31. if (_currentFrame >= frames.Length)
  32. _currentFrame = 0;
  33. }
  34. }
  35. }
  36. class Program
  37. {
  38. static void Main(string[] args)
  39. {
  40. var spiners = new List<Spiner>();
  41. while(spiners.Count<25)
  42. {
  43. spiners.Add(new Spiner() { X = spiners.Count, Y = spiners.Count });
  44. }
  45. var sw = new Stopwatch();
  46. sw.Start();
  47. foreach (var s in spiners)
  48. s.Run();
  49. while(sw.ElapsedMilliseconds<10000)
  50. { }
  51.  
  52. foreach (var s in spiners)
  53. s.IsComplite = true; ;
  54. }
  55. }
  56. }
  57.  
Time limit exceeded #stdin #stdout 5s 17844KB
stdin
Standard input is empty
stdout
\\\\\\\\\\\\\\\\\\\\\\\\\|||||||||||||||||||||||||/////////////////////////-------------------------\\\\\\\\\\\\\\\\\\\\\\\\\|||||||||||||||||||||||||/////////////////////////-------------------------\\\\\\\\\\\\\\\\\\\\\\\\\|||||||||||||||||||||||||