Skip to content

Commit a5d2378

Browse files
committed
ps
1 parent 076bdb6 commit a5d2378

10 files changed

Lines changed: 706 additions & 0 deletions

File tree

‎S5644.java‎

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
import java.io.*;
2+
3+
public class S5644 {
4+
5+
static int[] dx = {0, -1, 9, 1, 0};
6+
static int[] dy = {0, 0, 1, 0, -1};
7+
static int M;
8+
static int A;
9+
static int[][] person;
10+
static int[][] battery;
11+
static int[][] map;
12+
13+
public static void main(String[] args) throws IOException {
14+
BufferedReader buffer = new BufferedReader(new InputStreamReader(System.in));
15+
int T = Integer.parseInt(buffer.readLine());
16+
int t = 0;
17+
18+
while (T > t) {
19+
String[] input= buffer.readLine().split(" ");
20+
21+
person = new int[10][10];
22+
23+
M = Integer.parseInt(input[0]);
24+
A = Integer.parseInt(input[1]);
25+
26+
person = new int[2][M];
27+
28+
29+
for(int i = 0; i < 2; i++) {
30+
input = buffer.readLine().split(" ");
31+
for (int j = 0; j < M; i++) {
32+
person[i][j] = Integer.parseInt(input[j]);
33+
}
34+
}
35+
36+
for(int i = 0; i < A; i++){
37+
input = buffer.readLine().split(" ");
38+
for(int j = 0; j < 4; j++){
39+
battery[i][j] = Integer.parseInt(input[j]);
40+
}
41+
}
42+
for(int i = 0; i < M; i++){
43+
// person1(i);
44+
}
45+
46+
47+
}
48+
// person1이 지나간 자리는 1
49+
// person2이 지나간 자리는 2
50+
// person이 중복된 자리는 3
51+
// 이후 미리 깔아두고 베터리 배열에 넣기
52+
53+
54+
55+
56+
57+
}
58+
// public static void person1(int n){
59+
// int nx = x + dx[n];
60+
// }
61+
}

‎TIL/J13023_2.java‎

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
import java.util.*;
2+
import java.io.*;
3+
4+
public class J13023_2 {
5+
static LinkedList<Integer>[] list;
6+
static boolean[] visited;
7+
public static void main(String[] args)throws IOException {
8+
BufferedReader buffer = new BufferedReader(new InputStreamReader(System.in));
9+
String[] input = buffer.readLine().split(" ");
10+
11+
12+
13+
int n = Integer.parseInt(input[0]);
14+
int m = Integer.parseInt(input[1]);
15+
16+
list = new LinkedList[n+1];
17+
18+
for(int i = 0; i< n+1; i++) {
19+
list[i] = new LinkedList<>();
20+
}
21+
22+
for(int i = 0 ; i <m; i++) {
23+
input = buffer.readLine().split(" ");
24+
int start = Integer.parseInt(input[0]);
25+
int end = Integer.parseInt(input[1]);
26+
27+
list[start].add(end);
28+
list[end].add(start);
29+
}
30+
31+
for(int i = 0; i < n; i++) {
32+
visited = new boolean[n+1];
33+
DFS(i,0);
34+
}
35+
36+
System.out.println("0");
37+
38+
}
39+
public static void DFS(int node, int depth) {
40+
visited[node] = true;
41+
if(depth ==4) {
42+
System.out.println("1");
43+
System.exit(0);
44+
}
45+
46+
for(int i : list[node]) {
47+
if(!visited[i]) {
48+
DFS(i, depth+1);
49+
}
50+
}
51+
visited[node] = false;
52+
53+
}
54+
}

‎TIL/J15683.java‎

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
package TIL;
2+
3+
/*
4+
5+
CCTV 1 CCTV 2 CCTV 3 CCTV 4 CCTV 5
6+
| | |
7+
o-> <-o-> o-> <-o-> <-o->
8+
|
9+
6번은 벽
10+
11+
CCTV는 회전 시킬 수 있다. 회전은 항상 90도 방향으로 해야한다.
12+
감시하려고 하는 방향이 가로 또는 세로 방향이어야 한다.
13+
*/
14+
15+
16+
import java.io.*;
17+
import java.util.*;
18+
19+
public class J15683 {
20+
static int[][] arr;
21+
static int N;
22+
static int M;
23+
24+
static boolean[][] visited;
25+
26+
27+
public static void main(String[] args) throws IOException {
28+
BufferedReader buffer = new BufferedReader(new InputStreamReader(System.in));
29+
30+
String[] input = buffer.readLine().split(" ");
31+
32+
int R = Integer.parseInt(input[0]);
33+
int C = Integer.parseInt(input[1]);
34+
35+
arr = new int[R][C];
36+
37+
for(int i = 0; i< R; i++){
38+
input = buffer.readLine().split(" ");
39+
for(int j = 0; j < C; j++){
40+
arr[i][j]= Integer.parseInt(input[j]);
41+
}
42+
}
43+
44+
45+
46+
}
47+
48+
}

‎TIL/J2252_2.java‎

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
package TIL;
2+
3+
import java.io.*;
4+
import java.util.*;
5+
6+
public class J2252_2 {
7+
static LinkedList<Integer>[] list;
8+
static int[] arr;
9+
static int[] result;
10+
static int fIndex;
11+
12+
public static void main(String[] args) throws IOException {
13+
BufferedReader buffer = new BufferedReader(new InputStreamReader(System.in));
14+
15+
String[] input = buffer.readLine().split(" ");
16+
17+
int n = Integer.parseInt(input[0]);
18+
int m = Integer.parseInt(input[1]);
19+
list = new LinkedList[n+1];
20+
21+
for(int i = 0 ; i < n+1 ; i ++ ) {
22+
list[i] = new LinkedList<Integer>();
23+
}
24+
arr = new int[n+1];
25+
result = new int[n+1];
26+
int index = 0 ;
27+
for(int i = 0; i < m; i++){
28+
input = buffer.readLine().split(" ");
29+
int node = Integer.parseInt(input[0]);
30+
int edge = Integer.parseInt(input[1]);
31+
list[node].add(edge);
32+
arr[edge]++;
33+
}
34+
35+
for(int i = 1; i <= n; i ++){
36+
if(arr[i] == 0){
37+
index = i;
38+
break;
39+
}
40+
}
41+
42+
topology(index);
43+
44+
for(int i = 0 ; i< n; i++){
45+
System.out.print(result[i]+ " ");
46+
}
47+
System.out.println();
48+
}
49+
50+
public static void topology(int idx){
51+
52+
for(int edge : list[idx]){
53+
arr[edge]--;
54+
if(arr[edge] == 0){
55+
System.out.println("확인");
56+
result[fIndex++] = edge;
57+
topology(edge);
58+
}
59+
}
60+
}
61+
}

‎TIL/J3109.java‎

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
package TIL;
2+
3+
import java.io.*;
4+
import java.util.*;
5+
6+
public class J3109 {
7+
8+
static char[][] map;
9+
static int cnt;
10+
static boolean[][] visited;
11+
static int R;
12+
static int C;
13+
static int[] dx = new int[]{-1, 0, 1};
14+
static int[] dy = new int[]{1, 1, 1};
15+
public static void main(String[] args) throws IOException {
16+
BufferedReader buffer = new BufferedReader(new InputStreamReader(System.in));
17+
18+
String[] input = buffer.readLine().split(" ");
19+
20+
R = Integer.parseInt(input[0]);
21+
C = Integer.parseInt(input[1]);
22+
23+
map = new char[R][C];
24+
visited = new boolean[R][C];
25+
26+
for(int i = 0; i < R; i++){
27+
String str = buffer.readLine();
28+
for(int j = 0; j < C; j++){
29+
map[i][j] = str.charAt(j);
30+
}
31+
}
32+
33+
cnt=0;
34+
for (int i = 0; i < R; i++) {
35+
if(pip(i,0)) {
36+
cnt++;
37+
}
38+
}
39+
40+
41+
System.out.println(cnt);
42+
}
43+
public static boolean pip(int x, int y){
44+
if(y == C-1){
45+
return true;
46+
}
47+
for(int i = 0; i < 3; i++){
48+
int nx = x + dx[i];
49+
int ny = y + dy[i];
50+
51+
if(nx >=0 && nx< R && ny< C && map[nx][ny] == '.' && !visited[nx][ny]){
52+
visited[nx][ny] = true;
53+
if(pip(nx,ny)) return true;
54+
}
55+
}
56+
return false;
57+
}
58+
}

‎TIL/J6987.java‎

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
package TIL;
2+
3+
import java.io.*;
4+
import java.util.*;
5+
6+
public class J6987 {
7+
static int[][] play;
8+
static int n;
9+
10+
public static void main(String[] args) throws IOException {
11+
BufferedReader buffer = new BufferedReader(new InputStreamReader(System.in));
12+
13+
14+
int T = 4;
15+
int t = 0;
16+
while (T > t) {
17+
play = new int[6][3];
18+
String[] input = buffer.readLine().split(" ");
19+
for (int i = 0; i < 6; i++) {
20+
for (int j = 0; j < 3; j++) {
21+
play[i][j] = Integer.parseInt(input[(3*i)+j]);
22+
}
23+
}
24+
n=0;
25+
game(0, 0, 1, new int[6][3]);
26+
27+
System.out.print(n + " ");
28+
t++;
29+
}
30+
31+
}
32+
33+
public static void game(int r, int team, int opponent, int[][] result) {
34+
if (r == 15) {
35+
for (int i = 0; i < 6; i++) {
36+
for (int j = 0; j < 3; j++) {
37+
if (play[i][j] != result[i][j]) return;
38+
}
39+
}
40+
n = 1;
41+
return;
42+
}
43+
44+
if(opponent == 6) {
45+
team++;
46+
opponent = team+1;
47+
}
48+
49+
if(team >= 6 || opponent>=6) return;
50+
51+
result[team][0]++;
52+
result[opponent][2]++;
53+
game(r+1, team, opponent+1, result);
54+
result[team][0]--;
55+
result[opponent][2]--;
56+
57+
result[team][1]++;
58+
result[opponent][1]++;
59+
game(r+1, team, opponent+1, result);
60+
result[team][1]--;
61+
result[opponent][1]--;
62+
63+
result[team][2]++;
64+
result[opponent][0]++;
65+
game(r+1, team, opponent+1, result);
66+
result[team][2]--;
67+
result[opponent][0]--;
68+
69+
}
70+
71+
}

0 commit comments

Comments
 (0)