Submission #1150211

#TimeUsernameProblemLanguageResultExecution timeMemory
1150211lancethedragontrainerRMQ (NOI17_rmq)C++20
Compilation error
0 ms0 KiB
// For each tag A, we record the allowed interval where it must appear if it is used in a query. int[] allowedL = new int[N]; int[] allowedR = new int[N]; Arrays.fill(allowedL, 0); Arrays.fill(allowedR, N - 1); boolean[] hasQuery = new boolean[N]; // We will also generate events for a sweep‐line to compute LB[]. // Each query [L, R, A] gives an add event at L and (if R+1 < N) a remove event at R+1. int totalEvents = 2 * Q; Event[] events = new Event[totalEvents]; int eventCount = 0; // Temporarily store queries so we can update allowed intervals and create events. for (int i = 0; i < Q; i++) { st = new StringTokenizer(br.readLine()); int L = Integer.parseInt(st.nextToken()); int R = Integer.parseInt(st.nextToken()); int A = Integer.parseInt(st.nextToken()); // Update allowed interval for tag A. allowedL[A] = Math.max(allowedL[A], L); allowedR[A] = Math.min(allowedR[A], R); hasQuery[A] = true; events[eventCount++] = new Event(L, A, true); if (R + 1 < N) { events[eventCount++] = new Event(R + 1, A, false); } } // Sort the events by index (and add events before remove events when indices are equal). Arrays.sort(events, 0, eventCount); // Compute LB[i] for positions i = 0..N-1 using a sweep-line. // At position i, LB[i] is the maximum A among all queries covering i. int[] LB = new int[N]; TreeMap<Integer, Integer> active = new TreeMap<>(); int idxEvent = 0; for (int i = 0; i < N; i++) { while (idxEvent < eventCount && events[idxEvent].index == i) { Event e = events[idxEvent]; if (e.add) { active.put(e.val, active.getOrDefault(e.val, 0) + 1); } else { int cnt = active.get(e.val); if (cnt == 1) active.remove(e.val); else active.put(e.val, cnt - 1); } idxEvent++; } LB[i] = active.isEmpty() ? 0 : active.lastKey(); } // Build candidate lists for each value v: positions i with LB[i] == v. ArrayList<ArrayList<Integer>> candidates = new ArrayList<>(N); for (int v = 0; v < N; v++) { candidates.add(new ArrayList<>()); } for (int i = 0; i < N; i++) { candidates.get(LB[i]).add(i); } // For each tag A that appears in a query, we must assign it to a candidate position // in the allowed interval [allowedL[A], allowedR[A]]. int[] designatedPos = new int[N]; // designatedPos[A] holds the position chosen for tag A. Arrays.fill(designatedPos, -1); boolean possible = true; for (int A = 0; A < N; A++) { if (hasQuery[A]) { ArrayList<Integer> list = candidates.get(A); // Binary search in list for the smallest index >= allowedL[A] int pos = Collections.binarySearch(list, allowedL[A]); if (pos < 0) pos = -pos - 1; if (pos >= list.size() || list.get(pos) > allowedR[A]) { possible = false; break; } designatedPos[A] = list.get(pos); } } if (!possible) { StringBuilder sb = new StringBuilder(); for (int i = 0; i < N; i++) { sb.append("-1 "); } out.println(sb.toString().trim()); out.close(); return; } // Create the result array (positions 0..N-1) and assign the designated tags. int[] result = new int[N]; Arrays.fill(result, -1); boolean[] usedTag = new boolean[N]; for (int A = 0; A < N; A++) { if (hasQuery[A]) { int pos = designatedPos[A]; result[pos] = A; usedTag[A] = true; } } // Now, for every unassigned position, we must assign an unused tag X such that X >= LB[i]. // We use a TreeSet to hold all available tags. TreeSet<Integer> availTag = new TreeSet<>(); for (int tag = 0; tag < N; tag++) { if (!usedTag[tag]) availTag.add(tag); } for (int i = 0; i < N; i++) { if (result[i] == -1) { Integer tag = availTag.ceiling(LB[i]); if (tag == null) { possible = false; break; } result[i] = tag; availTag.remove(tag); } } if (!possible) { StringBuilder sb = new StringBuilder(); for (int i = 0; i < N; i++) { sb.append("-1 "); } out.println(sb.toString().trim()); } else { StringBuilder sb = new StringBuilder(); for (int i = 0; i < N; i++) { sb.append(result[i]); if (i < N - 1) sb.append(" "); } out.println(sb.toString().trim()); } out.close(); } // Helper class for events used in the sweep-line. static class Event implements Comparable<Event> { int index, val; boolean add; public Event(int index, int val, boolean add) { this.index = index; this.val = val; this.add = add; } public int compareTo(Event other) { if (this.index != other.index) return this.index - other.index; // When indices are equal, add events come before remove events. if (this.add == other.add) return 0; return this.add ? -1 : 1; } }

Compilation message (stderr)

rmq.cpp:2:8: error: structured binding declaration cannot have type 'int'
    2 |     int[] allowedL = new int[N];
      |        ^~
rmq.cpp:2:8: note: type must be cv-qualified 'auto' or reference to cv-qualified 'auto'
rmq.cpp:2:8: error: empty structured binding declaration
rmq.cpp:2:11: error: expected initializer before 'allowedL'
    2 |     int[] allowedL = new int[N];
      |           ^~~~~~~~
rmq.cpp:3:8: error: structured binding declaration cannot have type 'int'
    3 |     int[] allowedR = new int[N];
      |        ^~
rmq.cpp:3:8: note: type must be cv-qualified 'auto' or reference to cv-qualified 'auto'
rmq.cpp:3:8: error: empty structured binding declaration
rmq.cpp:3:11: error: expected initializer before 'allowedR'
    3 |     int[] allowedR = new int[N];
      |           ^~~~~~~~
rmq.cpp:4:5: error: 'Arrays' does not name a type
    4 |     Arrays.fill(allowedL, 0);
      |     ^~~~~~
rmq.cpp:5:5: error: 'Arrays' does not name a type
    5 |     Arrays.fill(allowedR, N - 1);
      |     ^~~~~~
rmq.cpp:6:5: error: 'boolean' does not name a type; did you mean 'bool'?
    6 |     boolean[] hasQuery = new boolean[N];
      |     ^~~~~~~
      |     bool
rmq.cpp:10:27: error: 'Q' was not declared in this scope
   10 |     int totalEvents = 2 * Q;
      |                           ^
rmq.cpp:11:5: error: 'Event' does not name a type
   11 |     Event[] events = new Event[totalEvents];
      |     ^~~~~
rmq.cpp:15:5: error: expected unqualified-id before 'for'
   15 |     for (int i = 0; i < Q; i++) {
      |     ^~~
rmq.cpp:15:25: error: 'Q' was not declared in this scope
   15 |     for (int i = 0; i < Q; i++) {
      |                         ^
rmq.cpp:15:25: error: 'Q' was not declared in this scope
rmq.cpp:15:25: error: 'Q' was not declared in this scope
rmq.cpp:15:25: error: 'Q' was not declared in this scope
rmq.cpp:15:25: error: 'Q' was not declared in this scope
rmq.cpp:15:25: error: 'Q' was not declared in this scope
rmq.cpp:15:25: error: 'Q' was not declared in this scope
rmq.cpp:15:25: error: 'Q' was not declared in this scope
rmq.cpp:15:25: error: 'Q' was not declared in this scope
rmq.cpp:15:21: error: 'i' does not name a type
   15 |     for (int i = 0; i < Q; i++) {
      |                     ^
rmq.cpp:15:28: error: 'i' does not name a type
   15 |     for (int i = 0; i < Q; i++) {
      |                            ^
rmq.cpp:30:5: error: 'Arrays' does not name a type
   30 |     Arrays.sort(events, 0, eventCount);
      |     ^~~~~~
rmq.cpp:34:8: error: structured binding declaration cannot have type 'int'
   34 |     int[] LB = new int[N];
      |        ^~
rmq.cpp:34:8: note: type must be cv-qualified 'auto' or reference to cv-qualified 'auto'
rmq.cpp:34:8: error: empty structured binding declaration
rmq.cpp:34:11: error: expected initializer before 'LB'
   34 |     int[] LB = new int[N];
      |           ^~
rmq.cpp:35:13: error: 'Integer' was not declared in this scope
   35 |     TreeMap<Integer, Integer> active = new TreeMap<>();
      |             ^~~~~~~
rmq.cpp:35:22: error: 'Integer' was not declared in this scope
   35 |     TreeMap<Integer, Integer> active = new TreeMap<>();
      |                      ^~~~~~~
rmq.cpp:35:13: error: 'Integer' was not declared in this scope
   35 |     TreeMap<Integer, Integer> active = new TreeMap<>();
      |             ^~~~~~~
rmq.cpp:35:22: error: 'Integer' was not declared in this scope
   35 |     TreeMap<Integer, Integer> active = new TreeMap<>();
      |                      ^~~~~~~
rmq.cpp:35:13: error: 'Integer' was not declared in this scope
   35 |     TreeMap<Integer, Integer> active = new TreeMap<>();
      |             ^~~~~~~
rmq.cpp:35:22: error: 'Integer' was not declared in this scope
   35 |     TreeMap<Integer, Integer> active = new TreeMap<>();
      |                      ^~~~~~~
rmq.cpp:35:13: error: 'Integer' was not declared in this scope
   35 |     TreeMap<Integer, Integer> active = new TreeMap<>();
      |             ^~~~~~~
rmq.cpp:35:22: error: 'Integer' was not declared in this scope
   35 |     TreeMap<Integer, Integer> active = new TreeMap<>();
      |                      ^~~~~~~
rmq.cpp:35:13: error: 'Integer' was not declared in this scope
   35 |     TreeMap<Integer, Integer> active = new TreeMap<>();
      |             ^~~~~~~
rmq.cpp:35:22: error: 'Integer' was not declared in this scope
   35 |     TreeMap<Integer, Integer> active = new TreeMap<>();
      |                      ^~~~~~~
rmq.cpp:35:13: error: 'Integer' was not declared in this scope
   35 |     TreeMap<Integer, Integer> active = new TreeMap<>();
      |             ^~~~~~~
rmq.cpp:35:22: error: 'Integer' was not declared in this scope
   35 |     TreeMap<Integer, Integer> active = new TreeMap<>();
      |                      ^~~~~~~
rmq.cpp:35:13: error: 'Integer' was not declared in this scope
   35 |     TreeMap<Integer, Integer> active = new TreeMap<>();
      |             ^~~~~~~
rmq.cpp:35:22: error: 'Integer' was not declared in this scope
   35 |     TreeMap<Integer, Integer> active = new TreeMap<>();
      |                      ^~~~~~~
rmq.cpp:35:13: error: 'Integer' was not declared in this scope
   35 |     TreeMap<Integer, Integer> active = new TreeMap<>();
      |             ^~~~~~~
rmq.cpp:35:22: error: 'Integer' was not declared in this scope
   35 |     TreeMap<Integer, Integer> active = new TreeMap<>();
      |                      ^~~~~~~
rmq.cpp:35:13: error: 'Integer' was not declared in this scope
   35 |     TreeMap<Integer, Integer> active = new TreeMap<>();
      |             ^~~~~~~
rmq.cpp:35:22: error: 'Integer' was not declared in this scope
   35 |     TreeMap<Integer, Integer> active = new TreeMap<>();
      |                      ^~~~~~~
rmq.cpp:35:5: error: 'TreeMap' does not name a type
   35 |     TreeMap<Integer, Integer> active = new TreeMap<>();
      |     ^~~~~~~
rmq.cpp:37:5: error: expected unqualified-id before 'for'
   37 |     for (int i = 0; i < N; i++) {
      |     ^~~
rmq.cpp:37:25: error: 'N' was not declared in this scope
   37 |     for (int i = 0; i < N; i++) {
      |                         ^
rmq.cpp:37:25: error: 'N' was not declared in this scope
rmq.cpp:37:25: error: 'N' was not declared in this scope
rmq.cpp:37:25: error: 'N' was not declared in this scope
rmq.cpp:37:25: error: 'N' was not declared in this scope
rmq.cpp:37:25: error: 'N' was not declared in this scope
rmq.cpp:37:25: error: 'N' was not declared in this scope
rmq.cpp:37:25: error: 'N' was not declared in this scope
rmq.cpp:37:25: error: 'N' was not declared in this scope
rmq.cpp:37:21: error: 'i' does not name a type
   37 |     for (int i = 0; i < N; i++) {
      |                     ^
rmq.cpp:37:28: error: 'i' does not name a type
   37 |     for (int i = 0; i < N; i++) {
      |                            ^
rmq.cpp:53:25: error: 'Integer' was not declared in this scope
   53 |     ArrayList<ArrayList<Integer>> candidates = new ArrayList<>(N);
      |                         ^~~~~~~
rmq.cpp:53:25: error: 'Integer' was not declared in this scope
rmq.cpp:53:25: error: 'Integer' was not declared in this scope
rmq.cpp:53:25: error: 'Integer' was not declared in this scope
rmq.cpp:53:25: error: 'Integer' was not declared in this scope
rmq.cpp:53:25: error: 'Integer' was not declared in this scope
rmq.cpp:53:25: error: 'Integer' was not declared in this scope
rmq.cpp:53:25: error: 'Integer' was not declared in this scope
rmq.cpp:53:25: error: 'Integer' was not declared in this scope
rmq.cpp:53:25: error: 'Integer' was not declared in this scope
rmq.cpp:53:25: error: 'Integer' was not declared in this scope
rmq.cpp:53:15: error: 'ArrayList' was not declared in this scope
   53 |     ArrayList<ArrayList<Integer>> candidates = new ArrayList<>(N);
      |               ^~~~~~~~~
rmq.cpp:53:25: error: 'Integer' was not declared in this scope
   53 |     ArrayList<ArrayList<Integer>> candidates = new ArrayList<>(N);
      |                         ^~~~~~~
rmq.cpp:53:25: error: 'Integer' was not declared in this scope
rmq.cpp:53:25: error: 'Integer' was not declared in this scope
rmq.cpp:53:25: error: 'Integer' was not declared in this scope
rmq.cpp:53:25: error: 'Integer' was not declared in this scope
rmq.cpp:53:25: error: 'Integer' was not declared in this scope
rmq.cpp:53:25: error: 'Integer' was not declared in this scope
rmq.cpp:53:25: error: 'Integer' was not declared in this scope
rmq.cpp:53:25: error: 'Integer' was not declared in this scope
rmq.cpp:53:25: error: 'Integer' was not declared in this scope
rmq.cpp:53:25: error: 'Integer' was not declared in this scope
rmq.cpp:53:25: error: 'Integer' was not declared in this scope
rmq.cpp:53:15: error: 'ArrayList' was not declared in this scope
   53 |     ArrayList<ArrayList<Integer>> candidates = new ArrayList<>(N);
      |               ^~~~~~~~~
rmq.cpp:53:25: error: 'Integer' was not declared in this scope
   53 |     ArrayList<ArrayList<Integer>> candidates = new ArrayList<>(N);
      |                         ^~~~~~~
rmq.cpp:53:25: error: 'Integer' was not declared in this scope
rmq.cpp:53:25: error: 'Integer' was not declared in this scope
rmq.cpp:53:25: error: 'Integer' was not declared in this scope
rmq.cpp:53:25: error: 'Integer' was not declared in this scope
rmq.cpp:53:25: error: 'Integer' was not declared in this scope
rmq.cpp:53:25: error: 'Integer' was not declared in this scope
rmq.cpp:53:25: error: 'Integer' was not declared in this scope
rmq.cpp:53:25: error: 'Integer' was not declared in this scope
rmq.cpp:53:25: error: 'Integer' was not declared in this scope
rmq.cpp:53:25: error: 'Integer' was not declared in this scope
rmq.cpp:53:25: error: 'Integer' was not declared in this scope
rmq.cpp:53:15: error: 'ArrayList' was not declared in this scope
   53 |     ArrayList<ArrayList<Integer>> candidates = new ArrayList<>(N);
      |               ^~~~~~~~~
rmq.cpp:53:25: error: 'Integer' was not declared in this scope
   53 |     ArrayList<ArrayList<Integer>> candidates = new ArrayList<>(N);
      |                         ^~~~~~~
rmq.cpp:53:25: error: 'Integer' was not declared in this scope
rmq.cpp:53:25: error: 'Integer' was not declared in this scope
rmq.cpp:53:25: error: 'Integer' was not declared in this scope
rmq.cpp:53:25: error: 'Integer' was not declared in this scope
rmq.cpp:53:25: error: 'Integer' was not declared in this scope
rmq.cpp:53:25: error: 'Integer' was not declared in this scope
rmq.cpp:53:25: error: 'Integer' was not declared in this scope
rmq.cpp:53:25: error: 'Integer' was not declared in this scope
rmq.cpp:53:25: error: 'Integer' was not declared in this scope
rmq.cpp:53:25: error: 'Integer' was not declared in this scope
rmq.cpp:53:25: error: 'Integer' was not declared in this scope
rmq.cpp:53:15: error: 'ArrayList' was not declared in this scope
   53 |     ArrayList<ArrayList<Integer>> candidates = new ArrayList<>(N);
      |               ^~~~~~~~~
rmq.cpp:53:25: error: 'Integer' was not declared in this scope
   53 |     ArrayList<ArrayList<Integer>> candidates = new ArrayList<>(N);
      |                         ^~~~~~~
rmq.cpp:53:25: error: 'Integer' was not declared in this scope
rmq.cpp:53:25: error: 'Integer' was not declared in this scope
rmq.cpp:53:25: error: 'Integer' was not declared in this scope
rmq.cpp:53:25: error: 'Integer' was not declared in this scope
rmq.cpp:53:25: error: 'Integer' was not declared in this scope
rmq.cpp:53:25: error: 'Integer' was not declared in this scope
rmq.cpp:53:25: error: 'Integer' was not declared in this scope
rmq.cpp:53:25: error: 'Integer' was not declared in this scope
rmq.cpp:53:25: error: 'Integer' was not declared in this scope
rmq.cpp:53:25: error: 'Integer' was not declared in this scope
rmq.cpp:53:25: error: 'Integer' was not declared in this scope
rmq.cpp:53:15: error: 'ArrayList' was not declared in this scope
   53 |     ArrayList<ArrayList<Integer>> candidates = new ArrayList<>(N);
      |               ^~~~~~~~~
rmq.cpp:53:25: error: 'Integer' was not declared in this scope
   53 |     ArrayList<ArrayList<Integer>> candidates = new ArrayList<>(N);
      |                         ^~~~~~~
rmq.cpp:53:25: error: 'Integer' was not declared in this scope
rmq.cpp:53:25: error: 'Integer' was not declared in this scope
rmq.cpp:53:25: error: 'Integer' was not declared in this scope
rmq.cpp:53:25: error: 'Integer' was not declared in this scope
rmq.cpp:53:25: error: 'Integer' was not declared in this scope
rmq.cpp:53:25: error: 'Integer' was not declared in this scope
rmq.cpp:53:25: error: 'Integer' was not declared in this scope
rmq.cpp:53:25: error: 'Integer' was not declared in this scope
rmq.cpp:53:25: error: 'Integer' was not declared in this scope
rmq.cpp:53:25: error: 'Integer' was not declared in this scope
rmq.cpp:53:25: error: 'Integer' was not declared in this scope
rmq.cpp:53:15: error: 'ArrayList' was not declared in this scope
   53 |     ArrayList<ArrayList<Integer>> candidates = new ArrayList<>(N);
      |               ^~~~~~~~~
rmq.cpp:53:25: error: 'Integer' was not declared in this scope
   53 |     ArrayList<ArrayList<Integer>> candidates = new ArrayList<>(N);
      |                         ^~~~~~~
rmq.cpp:53:25: error: 'Integer' was not declared in this scope
rmq.cpp:53:25: error: 'Integer' was not declared in this scope
rmq.cpp:53:25: error: 'Integer' was not declared in this scope
rmq.cpp:53:25: error: 'Integer' was not declared in this scope
rmq.cpp:53:25: error: 'Integer' was not declared in this scope
rmq.cpp:53:25: error: 'Integer' was not declared in this scope
rmq.cpp:53:25: error: 'Integer' was not declared in this scope
rmq.cpp:53:25: error: 'Integer' was not declared in this scope
rmq.cpp:53:25: error: 'Integer' was not declared in this scope
rmq.cpp:53:25: error: 'Integer' was not declared in this scope
rmq.cpp:53:25: error: 'Integer' was not declared in this scope
rmq.cpp:53:15: error: 'ArrayList' was not declared in this scope
   53 |     ArrayList<ArrayList<Integer>> candidates = new ArrayList<>(N);
      |               ^~~~~~~~~
rmq.cpp:53:25: error: 'Integer' was not declared in this scope
   53 |     ArrayList<ArrayList<Integer>> candidates = new ArrayList<>(N);
      |                         ^~~~~~~
rmq.cpp:53:25: error: 'Integer' was not declared in this scope
rmq.cpp:53:25: error: 'Integer' was not declared in this scope
rmq.cpp:53:25: error: 'Integer' was not declared in this scope
rmq.cpp:53:25: error: 'Integer' was not declared in this scope
rmq.cpp:53:25: error: 'Integer' was not declared in this scope
rmq.cpp:53:25: error: 'Integer' was not declared in this scope
rmq.cpp:53:25: error: 'Integer' was not declared in this scope
rmq.cpp:53:25: error: 'Integer' was not declared in this scope
rmq.cpp:53:25: error: 'Integer' was not declared in this scope
rmq.cpp:53:25: error: 'Integer' was not declared in this scope
rmq.cpp:53:25: error: 'Integer' was not declared in this scope
rmq.cpp:53:15: error: 'ArrayList' was not declared in this scope
   53 |     ArrayList<ArrayList<Integer>> candidates = new ArrayList<>(N);
      |               ^~~~~~~~~
rmq.cpp:53:25: error: 'Integer' was not declared in this scope
   53 |     ArrayList<ArrayList<Integer>> candidates = new ArrayList<>(N);
      |                         ^~~~~~~
rmq.cpp:53:25: error: 'Integer' was not declared in this scope
rmq.cpp:53:25: error: 'Integer' was not declared in this scope
rmq.cpp:53:25: error: 'Integer' was not declared in this scope
rmq.cpp:53:25: error: 'Integer' was not declared in this scope
rmq.cpp:53:25: error: 'Integer' was not declared in this scope
rmq.cpp:53:25: error: 'Integer' was not declared in this scope
rmq.cpp:53:25: error: 'Integer' was not declared in this scope
rmq.cpp:53:25: error: 'Integer' was not declared in this scope
rmq.cpp:53:25: error: 'Integer' was not declared in this scope
rmq.cpp:53:25: error: 'Integer' was not declared in this scope
rmq.cpp:53:25: error: 'Integer' was not declared in this scope
rmq.cpp:53:15: error: 'ArrayList' was not declared in this scope
   53 |     ArrayList<ArrayList<Integer>> candidates = new ArrayList<>(N);
      |               ^~~~~~~~~
rmq.cpp:53:25: error: 'Integer' was not declared in this scope
   53 |     ArrayList<ArrayList<Integer>> candidates = new ArrayList<>(N);
      |                         ^~~~~~~
rmq.cpp:53:5: error: 'ArrayList' does not name a type
   53 |     ArrayList<ArrayList<Integer>> candidates = new ArrayList<>(N);
      |     ^~~~~~~~~
rmq.cpp:54:5: error: expected unqualified-id before 'for'
   54 |     for (int v = 0; v < N; v++) {
      |     ^~~
rmq.cpp:54:25: error: 'N' was not declared in this scope
   54 |     for (int v = 0; v < N; v++) {
      |                         ^
rmq.cpp:54:25: error: 'N' was not declared in this scope
rmq.cpp:54:25: error: 'N' was not declared in this scope
rmq.cpp:54:25: error: 'N' was not declared in this scope
rmq.cpp:54:25: error: 'N' was not declared in this scope
rmq.cpp:54:25: error: 'N' was not declared in this scope
rmq.cpp:54:25: error: 'N' was not declared in this scope
rmq.cpp:54:25: error: 'N' was not declared in this scope
rmq.cpp:54:25: error: 'N' was not declared in this scope
rmq.cpp:54:21: error: 'v' does not name a type
   54 |     for (int v = 0; v < N; v++) {
      |                     ^
rmq.cpp:54:28: error: 'v' does not name a type
   54 |     for (int v = 0; v < N; v++) {
      |                            ^
rmq.cpp:57:5: error: expected unqualified-id before 'for'
   57 |     for (int i = 0; i < N; i++) {
      |     ^~~
rmq.cpp:57:25: error: 'N' was not declared in this scope
   57 |     for (int i = 0; i < N; i++) {
      |                         ^
rmq.cpp:57:25: error: 'N' was not declared in this scope
rmq.cpp:57:25: error: 'N' was not declared in this scope
rmq.cpp:57:25: error: 'N' was not declared in this scope
rmq.cpp:57:25: error: 'N' was not declared in this scope
rmq.cpp:57:25: error: 'N' was not declared in this scope
rmq.cpp:57:25: error: 'N' was not declared in this scope
rmq.cpp:57:25: error: 'N' was not declared in this scope
rmq.cpp:57:25: error: 'N' was not declared in this scope
rmq.cpp:57:21: error: 'i' does not name a type
   57 |     for (int i = 0; i < N; i++) {
      |                     ^
rmq.cpp:57:28: error: 'i' does not name a type
   57 |     for (int i = 0; i < N; i++) {
      |                            ^
rmq.cpp:63:8: error: structured binding declaration cannot have type 'int'
   63 |     int[] designatedPos = new int[N]; // designatedPos[A] holds the position chosen for tag A.
      |        ^~
rmq.cpp:63:8: note: type must be cv-qualified 'auto' or reference to cv-qualified 'auto'
rmq.cpp:63:8: error: empty structured binding declaration
rmq.cpp:63:11: error: expected initializer before 'designatedPos'
   63 |     int[] designatedPos = new int[N]; // designatedPos[A] holds the position chosen for tag A.
      |           ^~~~~~~~~~~~~
rmq.cpp:64:5: error: 'Arrays' does not name a type
   64 |     Arrays.fill(designatedPos, -1);
      |     ^~~~~~
rmq.cpp:65:5: error: 'boolean' does not name a type; did you mean 'bool'?
   65 |     boolean possible = true;
      |     ^~~~~~~
      |     bool
rmq.cpp:66:5: error: expected unqualified-id before 'for'
   66 |     for (int A = 0; A < N; A++) {
      |     ^~~
rmq.cpp:66:25: error: 'N' was not declared in this scope
   66 |     for (int A = 0; A < N; A++) {
      |                         ^
rmq.cpp:66:25: error: 'N' was not declared in this scope
rmq.cpp:66:25: error: 'N' was not declared in this scope
rmq.cpp:66:25: error: 'N' was not declared in this scope
rmq.cpp:66:25: error: 'N' was not declared in this scope
rmq.cpp:66:25: error: 'N' was not declared in this scope
rmq.cpp:66:25: error: 'N' was not declared in this scope
rmq.cpp:66:25: error: 'N' was not declared in this scope
rmq.cpp:66:25: error: 'N' was not declared in this scope
rmq.cpp:66:21: error: 'A' does not name a type
   66 |     for (int A = 0; A < N; A++) {
      |                     ^
rmq.cpp:66:28: error: 'A' does not name a type
   66 |     for (int A = 0; A < N; A++) {
      |                            ^
rmq.cpp:80:5: error: expected unqualified-id before 'if'
   80 |     if (!possible) {
      |     ^~
rmq.cpp:91:8: error: structured binding declaration cannot have type 'int'
   91 |     int[] result = new int[N];
      |        ^~
rmq.cpp:91:8: note: type must be cv-qualified 'auto' or reference to cv-qualified 'auto'
rmq.cpp:91:8: error: empty structured binding declaration
rmq.cpp:91:11: error: expected initializer before 'result'
   91 |     int[] result = new int[N];
      |           ^~~~~~
rmq.cpp:92:5: error: 'Arrays' does not name a type
   92 |     Arrays.fill(result, -1);
      |     ^~~~~~
rmq.cpp:93:5: error: 'boolean' does not name a type; did you mean 'bool'?
   93 |     boolean[] usedTag = new boolean[N];
      |     ^~~~~~~
      |     bool
rmq.cpp:94:5: error: expected unqualified-id before 'for'
   94 |     for (int A = 0; A < N; A++) {
      |     ^~~
rmq.cpp:94:25: error: 'N' was not declared in this scope
   94 |     for (int A = 0; A < N; A++) {
      |                         ^
rmq.cpp:94:25: error: 'N' was not declared in this scope
rmq.cpp:94:25: error: 'N' was not declared in this scope
rmq.cpp:94:25: error: 'N' was not declared in this scope
rmq.cpp:94:25: error: 'N' was not declared in this scope
rmq.cpp:94:25: error: 'N' was not declared in this scope
rmq.cpp:94:25: error: 'N' was not declared in this scope
rmq.cpp:94:25: error: 'N' was not declared in this scope
rmq.cpp:94:25: error: 'N' was not declared in this scope
rmq.cpp:94:21: error: 'A' does not name a type
   94 |     for (int A = 0; A < N; A++) {
      |                     ^
rmq.cpp:94:28: error: 'A' does not name a type
   94 |     for (int A = 0; A < N; A++) {
      |                            ^
rmq.cpp:104:13: error: 'Integer' was not declared in this scope
  104 |     TreeSet<Integer> availTag = new TreeSet<>();
      |             ^~~~~~~
rmq.cpp:104:13: error: 'Integer' was not declared in this scope
rmq.cpp:104:13: error: 'Integer' was not declared in this scope
rmq.cpp:104:13: error: 'Integer' was not declared in this scope
rmq.cpp:104:13: error: 'Integer' was not declared in this scope
rmq.cpp:104:13: error: 'Integer' was not declared in this scope
rmq.cpp:104:13: error: 'Integer' was not declared in this scope
rmq.cpp:104:13: error: 'Integer' was not declared in this scope
rmq.cpp:104:13: error: 'Integer' was not declared in this scope
rmq.cpp:104:5: error: 'TreeSet' does not name a type
  104 |     TreeSet<Integer> availTag = new TreeSet<>();
      |     ^~~~~~~
rmq.cpp:105:5: error: expected unqualified-id before 'for'
  105 |     for (int tag = 0; tag < N; tag++) {
      |     ^~~
rmq.cpp:105:29: error: 'N' was not declared in this scope
  105 |     for (int tag = 0; tag < N; tag++) {
      |                             ^
rmq.cpp:105:29: error: 'N' was not declared in this scope
rmq.cpp:105:29: error: 'N' was not declared in this scope
rmq.cpp:105:29: error: 'N' was not declared in this scope
rmq.cpp:105:29: error: 'N' was not declared in this scope
rmq.cpp:105:29: error: 'N' was not declared in this scope
rmq.cpp:105:29: error: 'N' was not declared in this scope
rmq.cpp:105:29: error: 'N' was not declared in this scope
rmq.cpp:105:29: error: 'N' was not declared in this scope
rmq.cpp:105:23: error: 'tag' does not name a type
  105 |     for (int tag = 0; tag < N; tag++) {
      |                       ^~~
rmq.cpp:105:32: error: 'tag' does not name a type
  105 |     for (int tag = 0; tag < N; tag++) {
      |                                ^~~
rmq.cpp:108:5: error: expected unqualified-id before 'for'
  108 |     for (int i = 0; i < N; i++) {
      |     ^~~
rmq.cpp:108:25: error: 'N' was not declared in this scope
  108 |     for (int i = 0; i < N; i++) {
      |                         ^
rmq.cpp:108:25: error: 'N' was not declared in this scope
rmq.cpp:108:25: error: 'N' was not declared in this scope
rmq.cpp:108:25: error: 'N' was not declared in this scope
rmq.cpp:108:25: error: 'N' was not declared in this scope
rmq.cpp:108:25: error: 'N' was not declared in this scope
rmq.cpp:108:25: error: 'N' was not declared in this scope
rmq.cpp:108:25: error: 'N' was not declared in this scope
rmq.cpp:108:25: error: 'N' was not declared in this scope
rmq.cpp:108:21: error: 'i' does not name a type
  108 |     for (int i = 0; i < N; i++) {
      |                     ^
rmq.cpp:108:28: error: 'i' does not name a type
  108 |     for (int i = 0; i < N; i++) {
      |                            ^
rmq.cpp:120:5: error: expected unqualified-id before 'if'
  120 |     if (!possible) {
      |     ^~
rmq.cpp:126:7: error: expected unqualified-id before 'else'
  126 |     } else {
      |       ^~~~
rmq.cpp:134:5: error: 'out' does not name a type
  134 |     out.close();
      |     ^~~
rmq.cpp:135:1: error: expected declaration before '}' token
  135 | }
      | ^
rmq.cpp:138:31: error: expected initializer before 'Comparable'
  138 | static class Event implements Comparable<Event> {
      |                               ^~~~~~~~~~