diff --git "a/khj20006/202503/20 BOJ G1 \353\262\204\354\212\244 \352\260\210\354\225\204\355\203\200\352\270\260.md" "b/khj20006/202503/20 BOJ G1 \353\262\204\354\212\244 \352\260\210\354\225\204\355\203\200\352\270\260.md" new file mode 100644 index 00000000..c1b02dbc --- /dev/null +++ "b/khj20006/202503/20 BOJ G1 \353\262\204\354\212\244 \352\260\210\354\225\204\355\203\200\352\270\260.md" @@ -0,0 +1,148 @@ +```java + +import java.util.*; +import java.io.*; + +class Bus{ + int x1, y1, x2, y2; + Bus(int x1, int y1, int x2, int y2){ + this.x1 = x1; + this.y1 = y1; + this.x2 = x2; + this.y2 = y2; + } + + boolean intersect(Bus other) { + + if(this.x1 == this.x2 && other.x1 == other.x2) { + if(this.x1 != other.x1) return false; + if(this.y1 > other.y2 || this.y2 < other.y1) return false; + return true; + } + + if(this.y1 == this.y2 && other.y1 == other.y2) { + if(this.y1 != other.y1) return false; + if(this.x1 > other.x2 || this.x2 < other.x1) return false; + return true; + } + + if(this.x1 == this.x2) { + if(other.x1 <= this.x1 && this.x1 <= other.x2 && this.y1 <= other.y1 && other.y1 <= this.y2) { + return true; + } + + return false; + } + if(other.y1 <= this.y1 && this.y1 <= other.y2 && this.x1 <= other.x1 && other.x1 <= this.x2) { + return true; + } + + return false; + } +} + +class Main { + + // IO field + static BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + static BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out)); + static StringTokenizer st = new StringTokenizer(""); + + static void nextLine() throws Exception {st = new StringTokenizer(br.readLine());} + static String nextToken() throws Exception { + if(!st.hasMoreTokens()) nextLine(); + return st.nextToken(); + } + static int nextInt() throws Exception { return Integer.parseInt(nextToken()); } + static long nextLong() throws Exception { return Long.parseLong(nextToken()); } + static double nextDouble() throws Exception { return Double.parseDouble(nextToken()); } + static void bwEnd() throws Exception {bw.flush();bw.close();} + + // Additional field + + static int M, N, K, sx, sy, ex, ey; + static Bus[] bs; + static boolean[] starts, ends; + + static boolean[][] V; + + public static void main(String[] args) throws Exception { + + ready(); + solve(); + + bwEnd(); + + } + + static void ready() throws Exception{ + + M = nextInt(); + N = nextInt(); + K = nextInt(); + bs = new Bus[K]; + V = new boolean[K][K]; + for(int i=0;i Q = new LinkedList<>(); + boolean[] vis = new boolean[K]; + for(int i=0;i