From 15be5239a465c80559db1fe7ed4edf07519abda4 Mon Sep 17 00:00:00 2001 From: oncsr Date: Wed, 2 Jul 2025 07:17:43 +0900 Subject: [PATCH] =?UTF-8?q?[20250702]=20BOJ=20/=20G3=20/=20=EB=8C=80?= =?UTF-8?q?=EB=8F=84=EC=8B=9C=20=EA=B5=AC=EC=B6=95=20/=20=EA=B6=8C?= =?UTF-8?q?=ED=98=81=EC=A4=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...4\354\213\234 \352\265\254\354\266\225.md" | 120 ++++++++++++++++++ 1 file changed, 120 insertions(+) create mode 100644 "khj20006/202507/02 BOJ G3 \353\214\200\353\217\204\354\213\234 \352\265\254\354\266\225.md" diff --git "a/khj20006/202507/02 BOJ G3 \353\214\200\353\217\204\354\213\234 \352\265\254\354\266\225.md" "b/khj20006/202507/02 BOJ G3 \353\214\200\353\217\204\354\213\234 \352\265\254\354\266\225.md" new file mode 100644 index 00000000..1c0ad1f2 --- /dev/null +++ "b/khj20006/202507/02 BOJ G3 \353\214\200\353\217\204\354\213\234 \352\265\254\354\266\225.md" @@ -0,0 +1,120 @@ +```java +import java.util.*; +import java.io.*; + +class IOController { + BufferedReader br; + BufferedWriter bw; + StringTokenizer st; + + public IOController() { + br = new BufferedReader(new InputStreamReader(System.in)); + bw = new BufferedWriter(new OutputStreamWriter(System.out)); + st = new StringTokenizer(""); + } + + String nextLine() throws Exception { + String line = br.readLine(); + st = new StringTokenizer(line); + return line; + } + + String nextToken() throws Exception { + while (!st.hasMoreTokens()) nextLine(); + return st.nextToken(); + } + + int nextInt() throws Exception { + return Integer.parseInt(nextToken()); + } + + long nextLong() throws Exception { + return Long.parseLong(nextToken()); + } + + double nextDouble() throws Exception { + return Double.parseDouble(nextToken()); + } + + void close() throws Exception { + bw.flush(); + bw.close(); + } + + void write(String content) throws Exception { + bw.write(content); + } + +} + +public class Main { + + static IOController io; + + // + + static int N, M; + static int[][] infos; + + public static void main(String[] args) throws Exception { + + io = new IOController(); + + init(); + solve(); + + io.close(); + + } + + public static void init() throws Exception { + + N = io.nextInt(); + M = io.nextInt(); + infos = new int[M][]; + for(int i=0;i a[0]==b[0] ? a[1]-b[1] : a[0]-b[0]); + long ans = (long)N*(N+1)/2 + N-2; + + if(M == 1) { + if(infos[0][0] == 1) { + if(infos[0][1] == 2) ans += 2; + else ans++; + } + } + else if(M == 2) { + int a = infos[0][0], b = infos[0][1]; + int aa = infos[1][0], bb = infos[1][1]; + if(a == 1 && aa == 1) { + if(b == 2) { + if(bb == 3) ans += 4; + else ans += 3; + } + else ans += 2; + } + else if(a == 1) { + if(b == 2) { + if(aa == 2 && bb == 3) ans += 3; + else ans += 2; + } + else { + if(aa == 2 && b == bb) { + if(b == 3) ans += 3; + else ans += 2; + } + else ans++; + } + } + } + + io.write(ans + "\n"); + + } + +} +```