https://www.acmicpc.net/problem/9093
근데.. 하나도 통과가 안됐다..
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Stack;
public class baekjoon_9093_01_시간초과 {
public static void main(String[] args) throws NumberFormatException, IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int TC = Integer.parseInt(br.readLine());
Stack<String> stack = new Stack<String>();
for(int tc = 0; tc < TC; tc ++) {
String[] temp1 = br.readLine().split(" ");
for(int i =0; i < temp1.length; i++) {
String[] temp2 = temp1[i].split("");
for(int j=0; j< temp2.length; j++) {
stack.push(temp2[j]);
}
for(int j=0; j< temp2.length; j++) {
System.out.print(stack.pop());
}
System.out.print(" ");
}
}
}
}
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Stack;
public class baekjoon_9093_02_시간초과 {
public static void main(String[] args) throws NumberFormatException, IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int TC = Integer.parseInt(br.readLine());
for(int tc = 0 ; tc < TC; tc++) {
Stack<String> stack = new Stack<String>();
String[] temp = br.readLine().split("");
for(int i = 0 ; i < temp.length; i++) {
if(temp[i].equals(" ") ) {
while(stack.size() > 0) {
System.out.print(stack.pop());
}
System.out.print(" ");
}else {
stack.push(temp[i]);
}
}
System.out.print(" ");
while(stack.size() > 0) {
System.out.print(stack.pop());
}
}
br.close();
}
}
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class baekjoon_9093_03_시간초과 {
public static void main(String[] args) throws NumberFormatException, IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int TC = Integer.parseInt(br.readLine());
for (int tc = 0; tc < TC; tc++) {
String[] temp = br.readLine().split(" ");
for (int i = 0; i < temp.length; i++) {
String[] temp2 = temp[i].split("");
for (int j = temp[i].length()-1; j >= 0; j--) {
System.out.print(temp2[j]);
}
System.out.print(" ");
}
}
}
}
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class baekjoon_9093_04_메모리초과 {
public static void main(String[] args) throws NumberFormatException, IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StringBuilder sb = new StringBuilder();
int TC = Integer.parseInt(br.readLine());
for (int tc = 0; tc < TC; tc++) {
String[] temp = br.readLine().split(" ");
for (int i = 0; i < temp.length; i++) {
String[] temp2 = temp[i].split("");
for (int j = temp[i].length()-1; j >= 0; j--) {
sb.append(temp2[j]);
}
sb.append(" ");
}
System.out.print(sb);
}
}
}
반응형
'코딩테스트준비' 카테고리의 다른 글
백준 9012 자바 (0) | 2020.09.19 |
---|---|
백준 10828 자바 (0) | 2020.09.19 |
백준 11022 자바 (0) | 2020.09.10 |
백준 11021 자바 (0) | 2020.09.10 |
백준 10953 자바 (0) | 2020.09.10 |