Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- import java.util.Stack;
- public class Main {
- public static void main(String[] args) {
- Scanner in = new Scanner(System.in);
- int casos = in.nextInt();
- in.nextLine();
- while (casos-- > 0) {
- if (in.next().equals("TT")) {
- Stack claus = new Stack();
- String linha = in.nextLine();
- boolean boolP = false;
- boolean boolQ = false;
- boolean boolR = false;
- boolean boolS = false;
- int variaveis = 0;
- for (int i = 0; i < linha.length(); i++) {
- if (linha.charAt(i) == 40) {
- int fim = 0;
- int parentesis = 1;
- for (int a = i + 1; parentesis != 0 && a < linha.length(); a++) {
- if (linha.charAt(a) == 40) {
- parentesis++;
- } else if (linha.charAt(a) == 41) {
- parentesis--;
- }
- fim = a;
- }
- claus.push(linha.substring(i + 1, fim));
- } else if (linha.charAt(i) == 80) {
- boolP = true;
- } else if (linha.charAt(i) == 81) {
- boolQ = true;
- } else if (linha.charAt(i) == 82) {
- boolR = true;
- } else if (linha.charAt(i) == 83) {
- boolS = true;
- }
- }
- if (boolP)
- variaveis++;
- if (boolQ)
- variaveis++;
- if (boolR)
- variaveis++;
- if (boolS)
- variaveis++;
- /*comeca a imprimir aqui*/
- if (variaveis == 1) {
- if (boolP) {
- for (int P = 0; P < 2; P++) {
- }
- } else if (boolQ) {
- for (int Q = 0; Q < 2; Q++) {
- }
- } else if (boolR) {
- for (int R = 0; R < 2; R++) {
- }
- } else {
- for (int S = 0; S < 2; S++) {
- }
- }
- } else if (variaveis == 2) {
- if (boolP && boolQ) {
- for (int P = 0; P < 2; P++) {
- for (int Q = 0; Q < 2; Q++) {
- }
- }
- } else if (boolP && boolR) {
- for (int P = 0; P < 2; P++) {
- for (int R = 0; R < 2; R++) {
- }
- }
- } else if (boolP && boolS) {
- for (int P = 0; P < 2; P++) {
- for (int S = 0; S < 2; S++) {
- }
- }
- } else if (boolQ && boolR) {
- for (int Q = 0; Q < 2; Q++) {
- for (int R = 0; R < 2; R++) {
- }
- }
- } else if (boolQ && boolS) {
- for (int Q = 0; Q < 2; Q++) {
- for (int S = 0; S < 2; S++) {
- }
- }
- } else {
- for (int R = 0; R < 2; R++) {
- for (int S = 0; S < 2; S++) {
- }
- }
- }
- } else if (variaveis == 3) {
- if (!boolS) {
- for (int P = 0; P < 2; P++) {
- for (int Q = 0; Q < 2; Q++) {
- for (int R = 0; R < 2; R++) {
- }
- }
- }
- } else if (!boolR) {
- for (int P = 0; P < 2; P++) {
- for (int Q = 0; Q < 2; Q++) {
- for (int S = 0; S < 2; S++) {
- }
- }
- }
- } else if (!boolQ) {
- for (int P = 0; P < 2; P++) {
- for (int R = 0; R < 2; R++) {
- for (int S = 0; S < 2; S++) {
- }
- }
- }
- } else {
- for (int Q = 0; Q < 2; Q++) {
- for (int R = 0; R < 2; R++) {
- for (int S = 0; S < 2; S++) {
- }
- }
- }
- }
- } else {
- for (int P = 0; P < 2; P++) {
- for (int Q = 0; Q < 2; Q++) {
- for (int R = 0; R < 2; R++) {
- for (int S = 0; S < 2; S++) {
- }
- }
- }
- }
- }
- }
- }
- in.close();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement