Advertisement
Guest User

Untitled

a guest
May 23rd, 2018
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.33 KB | None | 0 0
  1. import java.util.Scanner;
  2. import java.util.Stack;
  3.  
  4. public class Main {
  5.  
  6. public static void main(String[] args) {
  7. Scanner in = new Scanner(System.in);
  8. int casos = in.nextInt();
  9. in.nextLine();
  10. while (casos-- > 0) {
  11. if (in.next().equals("TT")) {
  12. Stack claus = new Stack();
  13. String linha = in.nextLine();
  14. boolean boolP = false;
  15. boolean boolQ = false;
  16. boolean boolR = false;
  17. boolean boolS = false;
  18. int variaveis = 0;
  19. for (int i = 0; i < linha.length(); i++) {
  20.  
  21. if (linha.charAt(i) == 40) {
  22. int fim = 0;
  23. int parentesis = 1;
  24.  
  25. for (int a = i + 1; parentesis != 0 && a < linha.length(); a++) {
  26. if (linha.charAt(a) == 40) {
  27. parentesis++;
  28. } else if (linha.charAt(a) == 41) {
  29. parentesis--;
  30. }
  31. fim = a;
  32. }
  33. claus.push(linha.substring(i + 1, fim));
  34. } else if (linha.charAt(i) == 80) {
  35. boolP = true;
  36. } else if (linha.charAt(i) == 81) {
  37. boolQ = true;
  38. } else if (linha.charAt(i) == 82) {
  39. boolR = true;
  40. } else if (linha.charAt(i) == 83) {
  41. boolS = true;
  42. }
  43. }
  44. if (boolP)
  45. variaveis++;
  46. if (boolQ)
  47. variaveis++;
  48. if (boolR)
  49. variaveis++;
  50. if (boolS)
  51. variaveis++;
  52.  
  53. /*comeca a imprimir aqui*/
  54.  
  55. if (variaveis == 1) {
  56. if (boolP) {
  57. for (int P = 0; P < 2; P++) {
  58.  
  59. }
  60. } else if (boolQ) {
  61. for (int Q = 0; Q < 2; Q++) {
  62.  
  63. }
  64. } else if (boolR) {
  65. for (int R = 0; R < 2; R++) {
  66.  
  67. }
  68. } else {
  69. for (int S = 0; S < 2; S++) {
  70.  
  71. }
  72. }
  73. } else if (variaveis == 2) {
  74. if (boolP && boolQ) {
  75. for (int P = 0; P < 2; P++) {
  76. for (int Q = 0; Q < 2; Q++) {
  77.  
  78. }
  79. }
  80. } else if (boolP && boolR) {
  81. for (int P = 0; P < 2; P++) {
  82. for (int R = 0; R < 2; R++) {
  83.  
  84. }
  85. }
  86. } else if (boolP && boolS) {
  87. for (int P = 0; P < 2; P++) {
  88. for (int S = 0; S < 2; S++) {
  89.  
  90. }
  91. }
  92. } else if (boolQ && boolR) {
  93. for (int Q = 0; Q < 2; Q++) {
  94. for (int R = 0; R < 2; R++) {
  95.  
  96. }
  97. }
  98. } else if (boolQ && boolS) {
  99. for (int Q = 0; Q < 2; Q++) {
  100. for (int S = 0; S < 2; S++) {
  101.  
  102. }
  103. }
  104. } else {
  105. for (int R = 0; R < 2; R++) {
  106. for (int S = 0; S < 2; S++) {
  107.  
  108. }
  109. }
  110. }
  111. } else if (variaveis == 3) {
  112. if (!boolS) {
  113. for (int P = 0; P < 2; P++) {
  114. for (int Q = 0; Q < 2; Q++) {
  115. for (int R = 0; R < 2; R++) {
  116.  
  117. }
  118. }
  119. }
  120. } else if (!boolR) {
  121. for (int P = 0; P < 2; P++) {
  122. for (int Q = 0; Q < 2; Q++) {
  123. for (int S = 0; S < 2; S++) {
  124.  
  125. }
  126. }
  127. }
  128. } else if (!boolQ) {
  129. for (int P = 0; P < 2; P++) {
  130. for (int R = 0; R < 2; R++) {
  131. for (int S = 0; S < 2; S++) {
  132.  
  133. }
  134. }
  135. }
  136. } else {
  137. for (int Q = 0; Q < 2; Q++) {
  138. for (int R = 0; R < 2; R++) {
  139. for (int S = 0; S < 2; S++) {
  140.  
  141. }
  142. }
  143. }
  144. }
  145.  
  146. } else {
  147. for (int P = 0; P < 2; P++) {
  148. for (int Q = 0; Q < 2; Q++) {
  149. for (int R = 0; R < 2; R++) {
  150. for (int S = 0; S < 2; S++) {
  151.  
  152. }
  153. }
  154. }
  155. }
  156. }
  157.  
  158. }
  159. }
  160. in.close();
  161. }
  162. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement