diff --git "a/02\354\233\224/1\354\243\274\354\260\250/[BOJ] \354\225\204\354\213\234\354\225\204 \354\240\225\353\263\264\354\230\254\353\246\274\355\224\274\354\225\204\353\223\234/Mun.java" "b/02\354\233\224/1\354\243\274\354\260\250/[BOJ] \354\225\204\354\213\234\354\225\204 \354\240\225\353\263\264\354\230\254\353\246\274\355\224\274\354\225\204\353\223\234/Mun.java" new file mode 100644 index 0000000..08dec47 --- /dev/null +++ "b/02\354\233\224/1\354\243\274\354\260\250/[BOJ] \354\225\204\354\213\234\354\225\204 \354\240\225\353\263\264\354\230\254\353\246\274\355\224\274\354\225\204\353\223\234/Mun.java" @@ -0,0 +1,36 @@ +import java.io.*; +import java.util.*; + +public class Mun { + public static void main(String[] args) throws IOException { + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + int N = Integer.parseInt(br.readLine()); + ArrayList list = new ArrayList<>(); + for(int i=0;i { + return o2[2] - o1[2]; + }); + StringBuilder sb = new StringBuilder(""); + int[] check = new int[N+1]; + int count = 1; + for(int[] arr : list) { + if(count == 3 && check[arr[0]] == 2) { + continue; + } + check[arr[0]]++; + sb.append(arr[0]).append(" ").append(arr[1]).append("\n"); + count++; + if(count > 3) { + break; + } + } + System.out.print(sb.toString()); + } +} \ No newline at end of file diff --git "a/02\354\233\224/1\354\243\274\354\260\250/[BOJ] \354\230\254\353\260\224\353\245\270 \353\260\260\354\227\264/Mun.java" "b/02\354\233\224/1\354\243\274\354\260\250/[BOJ] \354\230\254\353\260\224\353\245\270 \353\260\260\354\227\264/Mun.java" new file mode 100644 index 0000000..82ea54e --- /dev/null +++ "b/02\354\233\224/1\354\243\274\354\260\250/[BOJ] \354\230\254\353\260\224\353\245\270 \353\260\260\354\227\264/Mun.java" @@ -0,0 +1,29 @@ +import java.io.*; +import java.util.*; + +public class Mun { + public static void main(String[] args) throws IOException { + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + int N = Integer.parseInt(br.readLine()); + HashSet set = new HashSet<>(); + for(int i=0;i iterator = set.iterator(); + int min = 4; + while(iterator.hasNext()) { + long num = iterator.next(); + int p = 4; + for(long i=num+1;i que = new LinkedList<>(); + que.add(cr); + while(que.size() > 0) { + int now = que.poll(); + if(now > 0 && change[now-1] == 0 && (cogwheel[now][6] != cogwheel[now-1][2])) { + change[now-1] = change[now] * -1; + que.add(now-1); + } + if(now < 3 && change[now+1] == 0 && (cogwheel[now][2] != cogwheel[now+1][6])) { + change[now+1] = change[now] * -1; + que.add(now+1); + } + } + for(int j=0;j<4;j++) { + Rotation(j, change[j]); + } + } + + int[] score = {1, 2, 4, 8}; + int sum = 0; + for(int i=0;i<4;i++) { + if(cogwheel[i][0] == 1) { + sum+=score[i]; + } + } + System.out.print(sum); + } + + private static void Rotation(int num, int dir) { + if(dir == 0) { + return; + } + int[] copy = cogwheel[num].clone(); + int w = (dir > 0) ? -1 : 1; + for(int i=0;i<8;i++) { + int nuwD = i+w; + if(nuwD < 0) { + nuwD = 7; + } + cogwheel[num][i] = copy[nuwD%8]; + } + } +} \ No newline at end of file diff --git "a/02\354\233\224/1\354\243\274\354\260\250/[PRGRMS] \354\266\251\353\217\214\354\234\204\355\227\230 \354\260\276\352\270\260/Mun.java" "b/02\354\233\224/1\354\243\274\354\260\250/[PRGRMS] \354\266\251\353\217\214\354\234\204\355\227\230 \354\260\276\352\270\260/Mun.java" new file mode 100644 index 0000000..84d8556 --- /dev/null +++ "b/02\354\233\224/1\354\243\274\354\260\250/[PRGRMS] \354\266\251\353\217\214\354\234\204\355\227\230 \354\260\276\352\270\260/Mun.java" @@ -0,0 +1,79 @@ +import java.util.*; + +class Mun { + + class Robot { + int r, c, nextIdx; + boolean exited; + + public Robot(int r, int c, int nextIdx, boolean exited) { + this.r = r; + this.c = c; + this.nextIdx = nextIdx; + this.exited = exited; + } + } + + public int solution(int[][] points, int[][] routes) { + int n = routes.length; + Robot[] robots = new Robot[n]; + + for (int i=0;i count = new HashMap<>(); + boolean allExited = true; + + for(Robot rb : robots) { + if(rb.exited) { + continue; + } + + allExited = false; + int key = rb.r * 1000 + rb.c; + count.put(key, count.getOrDefault(key, 0) + 1); + } + + for(int v : count.values()) { + if(v >= 2) { + danger++; + } + } + + if(allExited) { + break; + } + + for (int i = 0; i < n; i++) { + Robot rb = robots[i]; + if(rb.exited) { + continue; + } + + if(rb.nextIdx == routes[i].length) { + rb.exited = true; + continue; + } + + int[] target = points[routes[i][rb.nextIdx] - 1]; + + if (rb.r != target[0]) { + rb.r += rb.r < target[0] ? 1 : -1; + } else if (rb.c != target[1]) { + rb.c += rb.c < target[1] ? 1 : -1; + } + + if (rb.r == target[0] && rb.c == target[1]) { + rb.nextIdx++; + } + } + } + + return danger; + } +}