Loading...

[swexpert] 7272. 안경이 없어 (JAVA, D3)

import java.util.Scanner; public class Solution { static int t; static String a="CEFGHIJKLMNSTUVWXYZ"; static String b="ADOPQR"; public static void main(String[] args) { Scanner sc=new Scanner(System.in); t=sc.nextInt(); for (int tc = 1; tc

[swexpert] 프로세서 연결하기 (java, dfs, 백트래킹)

import java.util.ArrayList; import java.util.List; import java.util.Scanner; public class Solution { static int t,n; static int[][] map; static List core; static boolean[][] vis; static int[] xpos= {1,-1,0,0}; static int[] ypos= {0,0,1,-1}; static int res; static int max_connect; public static void main(String[] args) { Scanner sc=new Scanner(System.in); t=sc.nextInt(); for (int tc = 1; tc res) ..

[swexpert] 2105. 디저트 카페 (java, 시뮬레이션, 모든 탐색)

좀 되는 대로 푼 시뮬 문제라서 다른 방법도 공부해야겠다 import java.util.Scanner; public class Solution { static int t,n; static int[][] map; static int [] xpos= {1,-1,-1,1}; static int [] ypos= {1,1,-1,-1}; static int ans; static boolean vis[]; static boolean vis_dir[]; static int sy,sx; public static void main(String[] args) { Scanner sc=new Scanner(System.in); t=sc.nextInt(); for (int tc = 1; tc

[swexpert] 3234. 준환이의 양팔 저울 (java, 완전탐색)

nPr을 먼저해서 n개의 무게추를 순서를 모두 다르게 정렬한 다음 subset으로 왼쪽 혹은 오른쪽(왼쪽의 무게가 더 높도록 제한)으로 넘겨주면서 무게를 계산한다. 가능한 경우의 수를 리턴한다. import java.util.ArrayList; import java.util.Scanner; public class Solution { static int n,t; static int weight[]; static int sum; static int answer; static ArrayList arr=new ArrayList(); public static void main(String[] args) { Scanner sc=new Scanner(System.in); t=sc.nextInt(); for (int ..

[swexpert] 4012. 요리사 (java)

import java.util.ArrayList; import java.util.Scanner; public class Solution { static int t,n; static int[][] table; static int answer; public static void main(String[] args) { Scanner sc=new Scanner(System.in); t=sc.nextInt(); for (int tc = 1; tc

[swexpert] 6808. 규영이와 인영이의 카드게임 (java, D3)

한 명의 카드 순서는 고정이라 다른 한 사람의 모든 카드 배열 9! 만큼 순열로 돌리면서 구하면 된다. 비기는 경우는 고려하지 않고 이기거나 지는 경우만 구한다 dfs로 nPr(순열)을 구현하자 import java.util.Scanner; public class Solution { static int t; static int card[]; static int a[],b[]; static int ans,ans2; static int sum,sum2; static int p[]; public static void main(String[] args) { Scanner sc=new Scanner(System.in); t=sc.nextInt(); for (int tc = 1; tc

[swexpert] 1233. 사칙연산 유효성 검사 (JAVA)

자기 자신이 숫자인데 부모도 숫자면 계산이 안된다. 자신의 인덱스가 짝수면 부모인덱스는 인덱스/2 이다. 양쪽 자식을 모두 검사하려고 했는데 부모가 잘못된 순간(자식이 숫자인데 부모가 숫자인 순간) false이므로 짝수 인덱스만 검사해줘도 되는듯하다 (사실 짜다말고 오른쪽 검사 빠뜨리고 넣었는데 통과됨. 띠옹) import java.util.Scanner; public class Solution { static int n; static char[] tree; static int cur; static int answer; public static void main(String[] args) { Scanner sc=new Scanner(System.in); for (int tc = 1; tc 0) { if(..

[swexpert] 1940. 가랏! RC카! (D2, JAVA)

import java.util.Scanner; public class Solution { static int t,n; static int x,speed; static int answer; public static void main(String[] args) { Scanner sc=new Scanner(System.in); t=sc.nextInt(); for (int tc = 1; tc

[swexpert] 9229. 한빈이와 Spot Mart (D3, java)

조합 문제이다. nC2를 구하면 된다. import java.util.Scanner; public class Solution { static int t; static int n,m; static int[] snack; static int answer; public static void main(String[] args) { Scanner sc=new Scanner(System.in); t=sc.nextInt(); for (int tc = 1; tc

[swexpert] 1228. 암호문1 (java, D3)

import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.StringTokenizer; public class Solution { static int n; static ArrayList password; public static void main(String[] args) throws IOException { BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st; int tc=1; String input="";..