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; + } + } + } + + } + +} + +```