-
Notifications
You must be signed in to change notification settings - Fork 4
[10주차] 이지영 #135
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
[10주차] 이지영 #135
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
aedc644
이지영: [CT] 회전하는 빙하_241111
yeongleej 30b308c
이지영: [BOJ] 1613 역사_241113
yeongleej b802c21
이지영: [BOJ] 2096 내려가기_241113
yeongleej 22af7a2
이지영: [SQL] Human Traffic of Stadium_241113
yeongleej 3136eed
이지영: [BOJ] 2955 스도쿠 풀기_241112
yeongleej 82008e2
이지영: [PG] 150366 표 병합_241114
yeongleej 655f25f
이지영: [PG] 181188 요격 시스템_241115
yeongleej 6bcb99a
이지영: [PG] 42884 단속카메라_241115
yeongleej 41d56e3
이지영: [SQL] 특정 형질을 가지는 대장균 찾기_241115
yeongleej File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
68 changes: 68 additions & 0 deletions
BOJ/1000-5000번/JY_1613.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
package day1113; | ||
|
||
import java.io.*; | ||
import java.util.*; | ||
|
||
public class JY_1613 { | ||
|
||
static final int INF = 50_000; | ||
|
||
public static void main(String[] args) throws IOException{ | ||
BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); | ||
StringTokenizer st = new StringTokenizer(br.readLine()); | ||
|
||
int N = Integer.parseInt(st.nextToken()); | ||
int K = Integer.parseInt(st.nextToken()); | ||
|
||
int[][] g = new int[N+1][N+1]; | ||
for(int i=0; i<N+1; i++) { | ||
Arrays.fill(g[i], INF); | ||
} | ||
// 자신으로가는 비용은 0으로 처리 | ||
for(int i=1; i<N+1; i++) { | ||
for(int j=1; j<N+1; j++) { | ||
if(i == j) g[i][j] = 0; | ||
} | ||
} | ||
|
||
for(int i=0; i<K; i++) { | ||
st = new StringTokenizer(br.readLine()); | ||
int a = Integer.parseInt(st.nextToken()); | ||
int b = Integer.parseInt(st.nextToken()); | ||
|
||
g[a][b] = 1; | ||
} | ||
|
||
// 플로이드 와샬: i -> j로 갈 수 있는 최단거리 구함 | ||
for(int k=1; k<N+1; k++) { | ||
for(int i=1; i<N+1; i++) { | ||
for(int j=1; j<N+1; j++) { | ||
g[i][j] = Math.min(g[i][j], g[i][k]+g[k][j]); | ||
} | ||
} | ||
} | ||
|
||
|
||
st = new StringTokenizer(br.readLine()); | ||
int S = Integer.parseInt(st.nextToken()); | ||
|
||
StringBuilder sb = new StringBuilder(); | ||
for(int s=0; s<S; s++) { | ||
st = new StringTokenizer(br.readLine()); | ||
int a = Integer.parseInt(st.nextToken()); | ||
int b = Integer.parseInt(st.nextToken()); | ||
|
||
if(g[a][b] != INF) { | ||
sb.append("-1\n"); | ||
} else if(g[b][a] != INF) { | ||
sb.append("1\n"); | ||
} else { | ||
sb.append("0\n"); | ||
} | ||
} | ||
|
||
System.out.println(sb.toString()); | ||
|
||
} | ||
|
||
} |
46 changes: 46 additions & 0 deletions
BOJ/1000-5000번/JY_2096.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package day1113; | ||
|
||
import java.io.*; | ||
import java.util.*; | ||
|
||
public class JY_2096 { | ||
|
||
public static void main(String[] args) throws IOException { | ||
BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); | ||
StringTokenizer st = new StringTokenizer(br.readLine()); | ||
|
||
int N = Integer.parseInt(st.nextToken()); | ||
int[][] dp1 = new int[N][3]; | ||
int[][] dp2 = new int[N][3]; | ||
|
||
for(int i=0; i<N; i++) { | ||
st = new StringTokenizer(br.readLine()); | ||
dp1[i][0] = Integer.parseInt(st.nextToken()); | ||
dp1[i][1] = Integer.parseInt(st.nextToken()); | ||
dp1[i][2] = Integer.parseInt(st.nextToken()); | ||
} | ||
|
||
for(int i=0; i<N; i++) { | ||
dp2[i][0] = dp1[i][0]; | ||
dp2[i][1] = dp1[i][1]; | ||
dp2[i][2] = dp1[i][2]; | ||
} | ||
|
||
for(int i=1; i<N; i++) { | ||
dp1[i][0] = dp1[i][0] + Math.min(dp1[i-1][0], dp1[i-1][1]); | ||
dp1[i][1] = dp1[i][1] + Math.min(dp1[i-1][0], Math.min(dp1[i-1][1], dp1[i-1][2])); | ||
dp1[i][2] = dp1[i][2] + Math.min(dp1[i-1][1], dp1[i-1][2]); | ||
|
||
dp2[i][0] = dp2[i][0] + Math.max(dp2[i-1][0], dp2[i-1][1]); | ||
dp2[i][1] = dp2[i][1] + Math.max(dp2[i-1][0], Math.max(dp2[i-1][1], dp2[i-1][2])); | ||
dp2[i][2] = dp2[i][2] + Math.max(dp2[i-1][1], dp2[i-1][2]); | ||
} | ||
|
||
int max = Math.max(dp2[N-1][0], Math.max(dp2[N-1][1], dp2[N-1][2])); | ||
int min = Math.min(dp1[N-1][0], Math.min(dp1[N-1][1], dp1[N-1][2])); | ||
|
||
System.out.println(max+" "+min); | ||
|
||
} | ||
|
||
} |
194 changes: 194 additions & 0 deletions
BOJ/1000-5000번/JY_2955.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,194 @@ | ||
package day1112; | ||
|
||
import java.io.*; | ||
import java.util.*; | ||
|
||
public class JY_2955 { | ||
|
||
static final int N = 9; | ||
static int[][] g; | ||
static boolean[][] visited; | ||
|
||
public static void main(String[] args) throws IOException { | ||
BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); | ||
|
||
g = new int[N][N]; | ||
for(int i=0; i<N; i++) { | ||
String s = br.readLine(); | ||
for(int j=0; j<N; j++) { | ||
if(s.charAt(j) == '.') { | ||
g[i][j] = 0; | ||
} else { | ||
g[i][j] = s.charAt(j) - '0'; | ||
} | ||
} | ||
} | ||
|
||
|
||
|
||
// cross hatching | ||
while(true) { | ||
boolean isDone = true; | ||
|
||
for(int n=1; n<=9; n++) { | ||
// 유효성 체크 | ||
if(!isValid(n)) { | ||
System.out.println("ERROR"); | ||
return; | ||
} | ||
int cnt = crossHatching(n); | ||
if(cnt > 0) isDone = false; | ||
} | ||
|
||
if(isDone) break; | ||
|
||
} | ||
|
||
printS(); | ||
|
||
} | ||
public static void printG() { | ||
for(int i=0; i<N; i++) { | ||
System.out.println(Arrays.toString(g[i])); | ||
} | ||
System.out.println(); | ||
} | ||
public static void printV() { | ||
for(int i=0; i<N; i++) { | ||
System.out.println(Arrays.toString(visited[i])); | ||
} | ||
System.out.println(); | ||
} | ||
public static void printS() { | ||
for(int i=0; i<N; i++) { | ||
for(int j=0; j<N; j++) { | ||
if(g[i][j] == 0) System.out.print("."); | ||
else System.out.print(g[i][j]); | ||
} | ||
System.out.println(); | ||
} | ||
} | ||
public static void fillLine(int x, int y) { | ||
// 세로줄 | ||
for(int i=0; i<N; i++) { | ||
visited[i][y] = true; | ||
} | ||
|
||
// 가로줄 | ||
for(int j=0; j<N; j++) { | ||
visited[x][j] = true; | ||
} | ||
|
||
} | ||
public static void fillSquare(int sx, int sy) { | ||
// 3*3 | ||
for(int i=sx; i<sx+3; i++) { | ||
for(int j=sy; j<sy+3; j++) { | ||
visited[i][j] = true; | ||
} | ||
} | ||
} | ||
public static void fillArea(int n) { | ||
for(int i=0; i<N; i += 3) { | ||
for(int j=0; j<N; j += 3) { | ||
for(int x=i; x<i+3; x++) { | ||
for(int y=j; y<j+3; y++) { | ||
if(g[x][y] == n) { | ||
fillLine(x, y); | ||
fillSquare(i, j); | ||
} | ||
if(g[x][y] != 0) { | ||
visited[x][y] = true; | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
public static boolean checkLine(int n) { | ||
for(int x=0; x<N; x++) { | ||
for(int y=0; y<N; y++) { | ||
if(g[x][y] != n) continue; | ||
|
||
// 세로줄 체크 | ||
int cnt = 0; | ||
for(int i=0; i<N; i++) { | ||
if(g[i][y] == n) cnt++; | ||
} | ||
if(cnt > 1) return false; | ||
|
||
// 기로즐 체크 | ||
cnt = 0; | ||
for(int j=0; j<N; j++) { | ||
if(g[x][j] == n) cnt++; | ||
} | ||
if(cnt > 1) return false; | ||
|
||
} | ||
} | ||
return true; | ||
} | ||
public static boolean checkBox(int n) { | ||
// 유효한 3 * 3 찾기 | ||
for(int i=0; i<N; i+=3) { | ||
for(int j=0; j<N; j += 3) { | ||
int cnt = 0; | ||
int empty = 0; | ||
for(int x=i; x<i+3; x++) { | ||
for(int y=j; y<j+3; y++) { | ||
if(g[x][y] == n) cnt++; | ||
if(!visited[x][y]) empty++; | ||
} | ||
} | ||
|
||
if(cnt > 1) return false; | ||
if(cnt == 0 && empty == 0) return false; | ||
} | ||
} | ||
return true; | ||
} | ||
public static boolean isValid(int n) { | ||
visited = new boolean[N][N]; | ||
|
||
fillArea(n); | ||
|
||
return checkBox(n) && checkLine(n); | ||
} | ||
public static int findSpot(int n) { | ||
// 유효한 3 * 3 찾기 | ||
int fCnt = 0; | ||
for(int i=0; i<N; i+=3) { | ||
for(int j=0; j<N; j += 3) { | ||
int cnt = 0; | ||
int empty = 0; | ||
int px = -1, py = -1; | ||
for(int x=i; x<i+3; x++) { | ||
for(int y=j; y<j+3; y++) { | ||
if(g[x][y] == n) cnt++; | ||
if(!visited[x][y]) { | ||
empty++; | ||
px = x; | ||
py = y; | ||
} | ||
} | ||
} | ||
// n이없고, 빈곳이 1개이면 => CrossHatching | ||
if(cnt == 0 && empty == 1) { | ||
visited[px][py] = true; | ||
g[px][py] = n; | ||
fillLine(px, py); | ||
fCnt++; | ||
} | ||
} | ||
} | ||
return fCnt; | ||
} | ||
public static int crossHatching(int n) { | ||
visited = new boolean[N][N]; | ||
fillArea(n); | ||
|
||
|
||
return findSpot(n); | ||
} | ||
|
||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.