From a375ebe795434bdf287eedf26cb70e0ab2d1e66d Mon Sep 17 00:00:00 2001 From: oncsr Date: Fri, 4 Apr 2025 17:44:23 +0900 Subject: [PATCH] =?UTF-8?q?[20250404]=20BOJ=20/=20G3=20/=20=ED=99=8D?= =?UTF-8?q?=EC=9D=B5=20=ED=88=AC=EC=96=B4=EB=A6=AC=EC=8A=A4=ED=8A=B8=20/?= =?UTF-8?q?=20=EA=B6=8C=ED=98=81=EC=A4=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...64\353\246\254\354\212\244\355\212\270.md" | 88 +++++++++++++++++++ 1 file changed, 88 insertions(+) create mode 100644 "khj20006/202504/04 G3 \355\231\215\354\235\265 \355\210\254\354\226\264\353\246\254\354\212\244\355\212\270.md" diff --git "a/khj20006/202504/04 G3 \355\231\215\354\235\265 \355\210\254\354\226\264\353\246\254\354\212\244\355\212\270.md" "b/khj20006/202504/04 G3 \355\231\215\354\235\265 \355\210\254\354\226\264\353\246\254\354\212\244\355\212\270.md" new file mode 100644 index 00000000..97277bcc --- /dev/null +++ "b/khj20006/202504/04 G3 \355\231\215\354\235\265 \355\210\254\354\226\264\353\246\254\354\212\244\355\212\270.md" @@ -0,0 +1,88 @@ +```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 = new StringTokenizer(""); + + static void nextLine() throws Exception {st = new StringTokenizer(br.readLine());} + static String nextToken() throws Exception { + while(!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 N, Q; + static int[] A; + static TreeSet T; + + public static void main(String[] args) throws Exception { + + ready(); + solve(); + + bwEnd(); + + } + + static void ready() throws Exception{ + + N = nextInt(); + Q = nextInt(); + T = new TreeSet<>(); + for(int i=0;i0;) { + int op, x; + op = nextInt(); + + if(op == 3) { + Integer temp = T.ceiling(cur); + int m1 = -1; + if(temp != null) { + m1 = temp; + bw.write((m1-cur) + "\n"); + continue; + } + temp = T.ceiling(0); + int m2 = -1; + if(temp != null) { + m2 = temp; + bw.write((N-cur+m2) + "\n"); + continue; + } + bw.write("-1\n"); + + } + else { + x = nextInt(); + if(op == 1) { + if(T.contains(x-1)) T.remove(x-1); + else T.add(x-1); + } + else { + cur = (cur + x) % N; + } + } + } + + } + +} + +```