fork download
  1. class M{
  2. static String c(int[] s){
  3. int a[] = new int[8],
  4. x = 0,
  5. y;
  6. for(; x < 3; x++){
  7. for(y = 0; y < 3; a[x] += s[x * 3 + y++]);
  8. for (y = 0; y < 3; a[x + 3] += s[y++ % 3]);
  9. }
  10. for(x = 0; x < 9; y = s[x],
  11. a[6] += x % 4 < 1
  12. ? y
  13. : 0,
  14. a[7] += x % 2 < 1 & x > 0 & x++ < 8
  15. ? y
  16. : 0);
  17. x = 0;
  18. for(int i : a){
  19. if(i > 2){
  20. return "win";
  21. }
  22. }
  23. for(int i : a){
  24. if(i < 1){
  25. return "loose";
  26. }
  27. }
  28. return "cat";
  29. }
  30.  
  31. public static void main(String[] a){
  32. /* xxo
  33.   xox
  34.   oox */
  35. System.out.println(c(new int[]{ 1, 1, 0, 1, 0, 1, 0, 0, 1 }));
  36. /* xxx
  37.   ooo
  38.   xxx */
  39. System.out.println(c(new int[]{ 1, 1, 1, 0, 0, 0, 1, 1, 1 }));
  40. /* xxo
  41.   oox
  42.   xox */
  43. System.out.println(c(new int[]{ 1, 1, 0, 0, 0, 1, 1, 0, 1 }));
  44. }
  45. }
Success #stdin #stdout 0.04s 711168KB
stdin
Standard input is empty
stdout
loose
win
cat