fork download
  1. // テトロミノ認識〜 横へな 2012.10.6
  2. // http://n...content-available-to-author-only...e.jp/hena/ord4tetroid/
  3.  
  4. // に対する答案。
  5.  
  6. using System;
  7. using System.Collections.Generic;
  8. using System.Text;
  9.  
  10. namespace ord4tetroid
  11. {
  12. static class Program
  13. {
  14. static string[] L = { "00011121", "00010210", "00102021", "02101112", "01112021", "00010212", "00011020", "00101112" };
  15. static string[] I = { "00010203", "00102030", };
  16. static string[] T = { "00101120", "01101112", "01101121", "00010211", };
  17. static string[] O = { "00011011", };
  18. static string[] S = { "00011112", "01101120", "01021011", "00101121", };
  19.  
  20. static string solve(string points)
  21. {
  22. int[] array = Array.ConvertAll(points.Split(','), int.Parse);
  23.  
  24. Array.Sort(array);
  25.  
  26. // 左上に寄せる
  27. while (Array.TrueForAll(array, i => i % 10 >= 1)) array = Array.ConvertAll(array, i => i - 1);
  28. while (Array.TrueForAll(array, i => i >= 10)) array = Array.ConvertAll(array, i => i - 10);
  29.  
  30. string inputStr = string.Join("", Array.ConvertAll(array, i => i.ToString("00")));
  31. if (Array.IndexOf(L, inputStr) != -1) return "L";
  32. if (Array.IndexOf(I, inputStr) != -1) return "I";
  33. if (Array.IndexOf(T, inputStr) != -1) return "T";
  34. if (Array.IndexOf(O, inputStr) != -1) return "O";
  35. if (Array.IndexOf(S, inputStr) != -1) return "S";
  36. return "-";
  37. }
  38.  
  39.  
  40. static void test(string input, string expected)
  41. {
  42. string result = solve(input);
  43. Console.WriteLine("input: {0} expected: {1} received: {2} Judge: {3}", input, expected, result, (expected == result ? "OK" : "NG"));
  44. if (result != expected) throw new ApplicationException();
  45. }
  46.  
  47. static void Main()
  48. {
  49. /*#1*/ test("55,55,55,55", "-");
  50. /*#2*/ test("07,17,06,05", "L");
  51. /*#3*/ test("21,41,31,40", "L");
  52. /*#4*/ test("62,74,73,72", "L");
  53. /*#5*/ test("84,94,74,75", "L");
  54. /*#6*/ test("48,49,57,47", "L");
  55. /*#7*/ test("69,89,79,68", "L");
  56. /*#8*/ test("90,82,91,92", "L");
  57. /*#9*/ test("13,23,03,24", "L");
  58. /*#10*/ test("24,22,25,23", "I");
  59. /*#11*/ test("51,41,21,31", "I");
  60. /*#12*/ test("64,63,62,65", "I");
  61. /*#13*/ test("49,69,59,79", "I");
  62. /*#14*/ test("12,10,21,11", "T");
  63. /*#15*/ test("89,99,79,88", "T");
  64. /*#16*/ test("32,41,43,42", "T");
  65. /*#17*/ test("27,16,36,26", "T");
  66. /*#18*/ test("68,57,58,67", "O");
  67. /*#19*/ test("72,62,61,71", "O");
  68. /*#20*/ test("25,24,15,14", "O");
  69. /*#21*/ test("43,54,53,42", "S");
  70. /*#22*/ test("95,86,76,85", "S");
  71. /*#23*/ test("72,73,84,83", "S");
  72. /*#24*/ test("42,33,32,23", "S");
  73. /*#25*/ test("66,57,67,58", "S");
  74. /*#26*/ test("63,73,52,62", "S");
  75. /*#27*/ test("76,68,77,67", "S");
  76. /*#28*/ test("12,11,22,01", "S");
  77. /*#29*/ test("05,26,06,25", "-");
  78. /*#30*/ test("03,11,13,01", "-");
  79. /*#31*/ test("11,20,00,21", "-");
  80. /*#32*/ test("84,95,94,86", "-");
  81. /*#33*/ test("36,56,45,35", "-");
  82. /*#34*/ test("41,33,32,43", "-");
  83. /*#35*/ test("75,94,84,95", "-");
  84. /*#36*/ test("27,39,28,37", "-");
  85. /*#37*/ test("45,34,54,35", "-");
  86. /*#38*/ test("24,36,35,26", "-");
  87. /*#39*/ test("27,27,27,27", "-");
  88. /*#40*/ test("55,44,44,45", "-");
  89. /*#41*/ test("70,73,71,71", "-");
  90. /*#42*/ test("67,37,47,47", "-");
  91. /*#43*/ test("43,45,41,42", "-");
  92. /*#44*/ test("87,57,97,67", "-");
  93. /*#45*/ test("49,45,46,48", "-");
  94. /*#46*/ test("63,63,52,72", "-");
  95. /*#47*/ test("84,86,84,95", "-");
  96. /*#48*/ test("61,60,62,73", "-");
  97. /*#49*/ test("59,79,69,48", "-");
  98. /*#50*/ test("55,57,77,75", "-");
  99. }
  100. }
  101. }
Success #stdin #stdout 0.04s 37152KB
stdin
Standard input is empty
stdout
input: 55,55,55,55 expected: - received: - Judge: OK
input: 07,17,06,05 expected: L received: L Judge: OK
input: 21,41,31,40 expected: L received: L Judge: OK
input: 62,74,73,72 expected: L received: L Judge: OK
input: 84,94,74,75 expected: L received: L Judge: OK
input: 48,49,57,47 expected: L received: L Judge: OK
input: 69,89,79,68 expected: L received: L Judge: OK
input: 90,82,91,92 expected: L received: L Judge: OK
input: 13,23,03,24 expected: L received: L Judge: OK
input: 24,22,25,23 expected: I received: I Judge: OK
input: 51,41,21,31 expected: I received: I Judge: OK
input: 64,63,62,65 expected: I received: I Judge: OK
input: 49,69,59,79 expected: I received: I Judge: OK
input: 12,10,21,11 expected: T received: T Judge: OK
input: 89,99,79,88 expected: T received: T Judge: OK
input: 32,41,43,42 expected: T received: T Judge: OK
input: 27,16,36,26 expected: T received: T Judge: OK
input: 68,57,58,67 expected: O received: O Judge: OK
input: 72,62,61,71 expected: O received: O Judge: OK
input: 25,24,15,14 expected: O received: O Judge: OK
input: 43,54,53,42 expected: S received: S Judge: OK
input: 95,86,76,85 expected: S received: S Judge: OK
input: 72,73,84,83 expected: S received: S Judge: OK
input: 42,33,32,23 expected: S received: S Judge: OK
input: 66,57,67,58 expected: S received: S Judge: OK
input: 63,73,52,62 expected: S received: S Judge: OK
input: 76,68,77,67 expected: S received: S Judge: OK
input: 12,11,22,01 expected: S received: S Judge: OK
input: 05,26,06,25 expected: - received: - Judge: OK
input: 03,11,13,01 expected: - received: - Judge: OK
input: 11,20,00,21 expected: - received: - Judge: OK
input: 84,95,94,86 expected: - received: - Judge: OK
input: 36,56,45,35 expected: - received: - Judge: OK
input: 41,33,32,43 expected: - received: - Judge: OK
input: 75,94,84,95 expected: - received: - Judge: OK
input: 27,39,28,37 expected: - received: - Judge: OK
input: 45,34,54,35 expected: - received: - Judge: OK
input: 24,36,35,26 expected: - received: - Judge: OK
input: 27,27,27,27 expected: - received: - Judge: OK
input: 55,44,44,45 expected: - received: - Judge: OK
input: 70,73,71,71 expected: - received: - Judge: OK
input: 67,37,47,47 expected: - received: - Judge: OK
input: 43,45,41,42 expected: - received: - Judge: OK
input: 87,57,97,67 expected: - received: - Judge: OK
input: 49,45,46,48 expected: - received: - Judge: OK
input: 63,63,52,72 expected: - received: - Judge: OK
input: 84,86,84,95 expected: - received: - Judge: OK
input: 61,60,62,73 expected: - received: - Judge: OK
input: 59,79,69,48 expected: - received: - Judge: OK
input: 55,57,77,75 expected: - received: - Judge: OK