From bde2be61be47610b2c543e65f4a1dc7bd43dea1b Mon Sep 17 00:00:00 2001 From: oncsr Date: Mon, 17 Feb 2025 17:53:03 +0900 Subject: [PATCH] =?UTF-8?q?[20250217]=20BOJ=20/=20P1=20/=20C.S.G.=20/=20?= =?UTF-8?q?=EA=B6=8C=ED=98=81=EC=A4=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 17 BOJ P1 C.S.G. .md | 110 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 110 insertions(+) create mode 100644 17 BOJ P1 C.S.G. .md diff --git a/17 BOJ P1 C.S.G. .md b/17 BOJ P1 C.S.G. .md new file mode 100644 index 00000000..6b376eea --- /dev/null +++ b/17 BOJ P1 C.S.G. .md @@ -0,0 +1,110 @@ +```java + +import java.util.*; +import java.io.*; + + +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; + + static void nextLine() throws Exception {st = new StringTokenizer(br.readLine());} + static int nextInt() {return Integer.parseInt(st.nextToken());} + static long nextLong() {return Long.parseLong(st.nextToken());} + static void bwEnd() throws Exception {bw.flush();bw.close();} + + // Additional field + static int N, M, K; + static int[] C, A, L, D, R; + static List G; + static int turnReverse; + + public static void main(String[] args) throws Exception { + + ready(); + //solve(); + + bwEnd(); + + } + + static void ready() throws Exception{ + + int T = Integer.parseInt(br.readLine()); + while(T-- > 0) { + turnReverse = 0; + nextLine(); + N = nextInt(); + M = nextInt(); + C = new int[N+1]; + TreeSet temp = new TreeSet<>(); + + nextLine(); + for(int i=0;i 75) { + turnReverse ^= 1; + continue; + } + if(a != 1) temp.add(a); + C[origin]++; + + } + K = temp.size(); + L = new int[K]; + int idx = 0; + for(int i:temp) L[idx++] = i; + + G = new ArrayList<>(); + for(int i=1;i<=N;i++) { + int res = 0; + if(C[i] == 0) continue; + for(int j=0;j