domain stringclasses 5
values | prompt stringlengths 409 9.12k | rubrics listlengths 6 15 | golden_answer stringlengths 1.14k 23.3k |
|---|---|---|---|
Machine Learning & Artificial Intelligence | # Hybrid Efficiency Block — Forward Pass Computation
A hybrid efficiency block processes $T = 4$ tokens in a $d = 8$-dimensional embedding space. The input $X \in \mathbb{R}^{4 \times 8}$ is sampled from `numpy.random.RandomState(37).randn(4, 8)`.
The block integrates four components. The input $X$ is first normalize... | [
{
"criterion": "Does the answer compute x_n[0,0] = -0.0638 and x_n[1,3] = 1.8106 from the RMSNorm step (values rounded to 4 decimal places)?",
"weight": 10
},
{
"criterion": "Does the answer compute y_ssm[0,0] = -0.3166 and y_ssm[2,3] = -0.1890 from the selective SSM recurrence (values rounded to 4 ... | ## Step 1: RMSNorm
Compute $\text{RMS}[i] = \sqrt{\frac{1}{8}\sum_j X[i,j]^2 + 10^{-5}}$, then $x_n[i,:] = X[i,:] / \text{RMS}[i]$.
- Token 0: $\text{RMS} = 0.85387136$, $x_n[0] = [-0.06378433,\; 0.78970686,\; 0.40597102,\; -1.52288300,\; 1.77838484,\; 1.15921877,\; 0.32520226,\; -0.52535941]$
- Token 1: $\text{RMS} ... |
Computer Systems & Operating Systems | # Distributed Operating Systems - Coordinated Execution Analysis (Deterministic Trace, Derived-Constants Spec)
## 0) Reading rules (AUTHORITATIVE)
This document contains:
- AUTHORITATIVE rules (must be followed)
- LEGACY notes (included for realism; must be ignored if they conflict)
If any statement conflicts, AUTHO... | [
{
"criterion": "Does the answer contain the exact line 'SNAPSHOT_TIMES_MS = [0,10,35,48,50]'?",
"weight": 5
},
{
"criterion": "Does the answer contain the exact line 'INTERVALS = [[0,10),[10,12),[12,20),[20,28),[28,30),[30,35),[35,38),[38,40),[40,45),[45,46),[46,48),[48,50)]'?",
"weight": 5
},... | ## 1) Compute derived timestamps from Q=10 and HALFQ=5
Q=10, HALFQ=5, ONE=1, TWO=2
t_P3_spawn = Q + TWO = 12
t_gc_read = 2*Q + (Q - TWO) = 20 + 8 = 28
t_pf_start = 28
t_pf_end = t_pf_start + Q = 28 + 10 = 38
t_timeout = 4*Q + HALFQ = 40 + 5 = 45
t_sleep_end = t_timeout + ONE = 46
t_cleanup_end = t_sleep_end + TWO = 4... |
Algorithms & Data Structures | ## Problem
You are given an `n × m` grid (`1 ≤ n,m ≤ 200`) filled with digits `0..9`.
For each digit `d` (`0..9`), you are also given a move vector `(a[d], b[d])` (each component in `[-200,200]`).
Define Wilbur’s movement rule:
- If Wilbur is currently at cell `(x,y)` and the digit there is `d`, then his **forced n... | [
{
"criterion": "The answer models the forced movement as a directed graph on the grid cells in which every vertex has outdegree exactly 1.",
"weight": 10
},
{
"criterion": "The answer states that when the forced next position is outside the grid, the transition is a self-loop (the cell transitions t... | ### 1) Build the functional graph of forced moves
Index each cell `(x,y)` as a vertex `v` (total `V = n*m ≤ 40000`).
Let `dig[v]` be its digit.
Compute the forced transition `to[v]`:
- Let `d = dig[v]`.
- Candidate `(nx, ny) = (x + a[d], y + b[d])`.
- If inside the grid: `to[v] = id(nx,ny)`, else `to[v] = v` (self-... |
Algorithms & Data Structures | You are given a tree with `n` vertices (`1` to `n`). Vertex `v` has color `c_v ∈ [1..n]`.
A simple path is **beautiful** if:
1. it has at least 2 vertices;
2. its endpoints have the same color;
3. no other vertex on the path has that endpoint color.
Paths are **undirected**.
### Input
- `n` (`2 ≤ n ≤ 2·10^5`)
- colo... | [
{
"criterion": "Does the answer define a rooted tree (choose any root, e.g. 1) and process vertices in postorder (children before parent)?",
"weight": 10
},
{
"criterion": "Does the answer define cnt[v][x] as the number of vertices of color x in subtree(v) such that the path from v to that vertex co... | ### Expert Solution
Root the tree arbitrarily (e.g. at vertex 1) and process vertices in postorder.
#### 1) Top-level counts
For each vertex `v`, maintain a map `cnt[v]` where:
`cnt[v][x] = #{ w ∈ subtree(v) : c_w = x and there is no other x on the path v → w }`
So `w` is **`x`-top-level w.r.t. `v`**.
This “top-le... |
Algorithms & Data Structures | ## Problem: Maximum Possible Score of One Player Under Greedy Picks
You are given `n` distinct items labeled `1..n`, with exactly one copy of each item. Each item `i` has an integer score `v[i]` (scores may be negative).
Two players, **A** and **B**, each have a complete ranking (a permutation) of the items:
- `A[1.... | [
{
"criterion": "Does the response define p[i] as Bob’s position of item a[i] in Bob’s permutation?",
"weight": 10
},
{
"criterion": "Does the response state the DP initialization dp[0] = 0?",
"weight": 10
},
{
"criterion": "Does the response state that the final answer equals max(dp[j]) ... | ### 1) Renaming so that Alice’s list becomes `1,2,...,n`
Let the original item IDs be `1..n`. Define:
- `a[1..n]`: Alice’s permutation (most preferred first)
- `b[1..n]`: Bob’s permutation
- `v[id]`: value of item `id`
Relabel items by **Alice-rank**:
- The item with Alice-rank `i` is `id = a[i]`.
- Define `val[i] ... |
Algorithms & Data Structures | You have a strip of `1 × 10^9` cells numbered `1` to `10^9`.
There are `n` snakes (numbered `1` to `n`). Initially, each snake occupies exactly one cell, and no two snakes can be placed in the same cell. After placement, the game runs for `q` seconds. Each second exactly one event occurs:
- **Snake `s_i` enlarges:** ... | [
{
"criterion": "Does the solution state the final answer as min over last of ( d[(1<<n)-1][last] + plusCount[last] ), where plusCount[k] is the number of '+' events of snake k?",
"weight": 20
},
{
"criterion": "Does the solution state the score for a fixed permutation p1..pn as 1 + (sum of gaps betw... | ## Expert Answer
Key idea: placing snakes left-to-right defines a permutation; for any fixed order the best placement is greedy (minimum feasible gaps), and we can compute the required minimum gaps from the event log.
### 1) Reduce to an order (permutation)
In any valid placement, the snakes appear left-to-right in s... |
Algorithms & Data Structures | ## Problem
Denis defines a non-commutative “multiplication” of strings.
For a string `s` of length `m` and a string `t`, define:
\[
s \cdot t = t + s_1 + t + s_2 + \dots + t + s_m + t
\]
where \(s_i\) is the \(i\)-th character of `s`, and `+` means concatenation.
Examples:
- `"abc" ⋅ "de" = "deadebdecde"`
- `"ab"... | [
{
"criterion": "The answer states that the operation satisfies associativity: (a·b)·c = a·(b·c).",
"weight": 10
},
{
"criterion": "The answer computes the product by folding from right to left using P_n = p_n and P_i = p_i · P_{i+1}?",
"weight": 10
},
{
"criterion": "The answer introduce... | ### 1) Use associativity and fold from right to left
The operation is associative:
\[
(a\cdot b)\cdot c = a\cdot(b\cdot c)
\]
(you can verify by expanding both sides; both produce alternating blocks of the right operand with single characters of the left operands inserted in the same order).
So instead of building th... |
Algorithms & Data Structures | An autonomous vehicle navigation system uses a bidirectional time-dependent Dijkstra algorithm to compute an optimal route on a directed graph
G with 12 nodes labeled N0 through N11 and the following directed edges with base travel times in seconds:
(N0,N1,45), (N0,N2,60), (N1,N3,50), (N1,N4,70), (N2,N4,55), (N2,N5,80... | [
{
"criterion": "Does the answer state the forward expansion sequence exactly as [N0, N1, N2, N3, N5, N4, N6, N8, N9]?",
"weight": 20
},
{
"criterion": "Does the answer state the backward expansion sequence exactly as [N11, N10, N9, N7, N6, N8, N5, N4]?",
"weight": 20
},
{
"criterion": "D... | (1) Forward Expansion Sequence
Forward search starts at N0 at time t = 0 and applies time-dependent weights.
Expand N0 (0)
→ insert N1(45), N2(60)
Expand N1 (45)
→ insert N3(95), N4(171) [70 × 1.8 due to N4 window]
Expand N2 (60)
→ update N4(159) [55 × 1.8], insert N5(140)
Expand N3 (95)
→ insert N6(160)
Expand N... |
Algorithms & Data Structures | A miner is searching a rooted underground shaft system that forms a **tree** of `n` chambers (nodes) connected by one-way-less tunnels (undirected edges). A single phantom hides in exactly one chamber; initially it may be in any chamber. The miner can perform two kinds of actions. After each action, the phantom may (or... | [
{
"criterion": "Does the solution include a postorder coloring procedure that specifies how to label each node as 'green', 'yellow', or 'black' using only information from its children?",
"weight": 10
},
{
"criterion": "Does the solution assert that after removing every node labeled 'black', every c... | **Idea in one line.**
Cut a carefully chosen small set of nodes so the remaining connected pieces are simple paths, then “sweep” each path by checking its nodes from one end to the other. Do all cuts first (they only restrict the phantom), then do the sweeps. The number of cuts is at most `⌊n/4⌋`, so the total number... |
Algorithms & Data Structures | An Arbor Network is an undirected, connected, acyclic graph (i.e., a tree) with N junctions numbered 1 through N.
Every morning, R rival couriers traverse the network simultaneously. Rival i starts at junction s_i and travels to junction t_i along the unique shortest path in the tree. If that path is the vertex sequen... | [
{
"criterion": "Does the answer explicitly state the finite search horizon bound t* ≤ 2N + 1?",
"weight": 1
},
{
"criterion": "Does the answer explicitly define a forbidden pair (u, t) as: some rival occupies vertex u at integer time t during its travel?",
"weight": 1
},
{
"criterion": "... | Explicit finite time horizon: t* ≤ 2N + 1
Let t* be the earliest arrival time at B among all collision-free schedules, if any exist.
Claim. If a collision-free schedule exists, then t* ≤ 2N + 1.
Reason (sketch). Each rival walks a simple tree path of length at most N, so all rivals have finished moving by time ≤ N, h... |
Algorithms & Data Structures | Consider an n x m grid (2 <= n <= 12, 2 <= m <= 1000) where some cells are blocked. A Hamiltonian path visits every non-blocked cell exactly once. The task is to count Hamiltonian paths from cell (0,0) to cell (n-1, m-1), modulo 10^9+7. The grid is given as n lines of m characters where '.' is empty and '#' is blocked.... | [
{
"criterion": "The response states that the broken profile has exactly n+1 plug positions for an n-row grid, and describes the profile as consisting of n horizontal segments and 1 vertical segment (or equivalently as a staircase or L-shaped boundary).",
"weight": 10
},
{
"criterion": "The response ... | 1. PROFILE STRUCTURE:
The broken profile is the boundary between processed cells (above and to the left of the current cell in column-major order) and unprocessed cells (below and to the right). It forms a staircase or L-shaped boundary consisting of exactly n horizontal segments and 1 vertical segment. The profile has... |
Algorithms & Data Structures | You are fighting a vertical column of `n` enemies arranged in a single stack.
- Enemy `1` is at the bottom, enemy `n` is at the top.
- Enemy `i` starts with health `h[i]`.
### Attack rule
In one hit, you may choose **any currently alive enemy** (in any stack that exists at that moment) and reduce its health by `1`.
... | [
{
"criterion": "Does the answer define dp[i] as the minimum number of attacks needed to eliminate mobs 1 through i?",
"weight": 10
},
{
"criterion": "Does the answer state that the final output for a test case equals dp[n]?",
"weight": 10
},
{
"criterion": "Does the answer state that a m... | ### Key observations
1. **A creature can receive fall damage at most once.**
After it falls, it becomes the bottom of its new stack, and nothing can later fall “under it” again.
2. **If a creature ever receives fall damage greater than 1,** then the creature directly below it must have been killed by sword hits (... |
Algorithms & Data Structures | You are given a tree with `n` nodes. Node `i` has an allowed initial value interval `[l_i, r_i]`.
You choose initial values `a_i` such that:
`l_i ≤ a_i ≤ r_i`
A tree is **balanced** if all node values are equal; the balanced value is that common value.
**Operation:** choose two nodes `u` and `v`. Consider the tree ro... | [
{
"criterion": "Does the answer state that for an edge between parent p and child v (in a chosen rooting), choosing (u=p,v=v) increases (a_v−a_p) by 1 and choosing (u=v,v=p) decreases (a_v−a_p) by 1 (i.e., one operation changes the edge difference by exactly ±1)?",
"weight": 10
},
{
"criterion": "Do... | ### Expert Solution
Root the tree at node `1`. Let `p(v)` be the parent of `v`.
---
### A) Final balanced value for fixed initial values `a`
Consider an edge `(p, v)`.
An operation “increment subtree of `v` when rooted at `u`” can be used in two relevant ways for this edge:
- Choose `u = p`, `v = v`: increments t... |
Algorithms & Data Structures | ## Problem: Eliminate “+1 Later” Conflicts
You are given an integer sequence `a` of length `n`. Call a sequence `b` **valid** if there are **no** positions `i < j` such that:
\[
b_j = b_i + 1
\]
In other words, you must avoid any situation where a value appears and **somewhere later** a value exactly **one larger** ... | [
{
"criterion": "Does the answer state the forbidden pattern as existence of indices i<j with b[j] = b[i] + 1?",
"weight": 1
},
{
"criterion": "Does the answer sort the pair list by value in non-decreasing order?",
"weight": 1
},
{
"criterion": "Does the answer define dp[i] as the maximum... | ### Key reformulation
We want to keep as many elements as possible. Let `keep` be the maximum size of a subsequence that is **good**; then the answer is:
\[
\text{removed} = n - keep
\]
A subsequence is **not good** exactly when it contains two chosen indices `p<q` with `a[q]=a[p]+1`.
So, if we choose some elements o... |
Programming Languages, Compilers & Formal Methods | You are given a linear scan register allocation problem with 3 physical registers: R0, R1, R2.
Live intervals for virtual registers:
V0: [0,7]
V1: [1,5]
V2: [2,9]
V3: [3,6]
V4: [4,11]
V5: [6,10]
V6: [8,14]
V7: [10,13]
V8: [12,15]
V9: [1,3]
Use the following deterministic rules:
1. Process intervals in ascending ord... | [
{
"criterion": "Lists the processing order exactly as V0, V9, V1, V2, V3, V4, V5, V6, V7, V8.",
"weight": 15
},
{
"criterion": "States that the total number of spill events is exactly 2.",
"weight": 10
},
{
"criterion": "Identifies the first spill event as V2.",
"weight": 10
},
{... | Processing Order: V0, V9, V1, V2, V3, V4, V5, V6, V7, V8
Spill Events: V2, V4
Active Count 3 At: 1, 2, 3, 4, 12
Final Register Assignments:
V0 -> R0
V1 -> R2
V3 -> R1
V5 -> R1
V6 -> R0
V7 -> R1
V8 -> R2
V9 -> R1
Explanation
Step 1: Determine processing order
Intervals are sorted by increasing start point, and ties a... |
Algorithms & Data Structures | Steve is trapped in a tunnel filled with hostile creepers. There are n creepers standing in a straight line, indexed from 1 to n.
For each position i, the creeper at that position has an explosive power e_i.
We use the term “creepers” consistently throughout; all entities referred to are the same.
Explosion Rule:
If ... | [
{
"criterion": "Does the answer explicitly define the detonation interval of creeper i as [i − e_i + 1, i + e_i − 1]?",
"weight": 10
},
{
"criterion": "Does the answer state that two creepers cannot both be detonated if one lies inside the other’s detonation interval ?",
"weight": 10
},
{
... | Notation:
We use e_i to denote the explosive power of the creeper at position i, exactly as defined in the task prompt.
Detonation Interval:
Detonating creeper i kills all creepers in the interval:
[i − e_i + 1, i + e_i − 1]
Two creepers cannot both be detonated if their detonation intervals overlap in a way that one... |
Algorithms & Data Structures | # Odd-Quorum Rewrite Maximization — Extended Deterministic Output
You are given `t` test cases. In each test case:
- an array `a` of `n` **positive integers**
- a positive integer `k`
You may apply a "rewrite" operation that overwrites selected elements by a median.
---
## Rewrite game (per test case)
1. Choose on... | [
{
"criterion": "The reasoning contains an exhaustive enumeration of F(i, y) for every valid (i, y) pair in every one of the five test cases, i.e. for each test case and for every i in [1, n] every y in [0, min(i-1, n-i)] is listed together with its computed L, leftGain, rightLoss, and F(i, y) value. A partial e... | # Golden Answer
## Approach
We follow the computation path mandated by the prompt: sort the array, build prefix sums, apply the fixed reduction `F(i, y) = S + L·b[i] - p[L] - (p[i+y] - p[i]) + y·b[i]` with `L = min(k·y, i-1)`, and then **exhaustively enumerate every valid `(i, y)` pair** with `1 ≤ i ≤ n` and `0 ≤ y ≤... |
Computer Systems & Operating Systems | # PROMPT
Simulate Tomasulo's Algorithm for out-of-order execution with the following configuration:
EXECUTION LATENCIES (by instruction type):
- ADD/SUB: 2 cycles
- MUL: 4 cycles
- DIV: 8 cycles
- LOAD: 3 cycles (includes memory access)
RESERVATION STATIONS:
- 3 Add/Sub stations: Add1, Add2, Add3
- 2 Mul/Div station... | [
{
"criterion": "The response states that I3 (MUL) begins execution in exactly cycle 7.",
"weight": 10
},
{
"criterion": "The response states that I5 (DIV) writes its result in exactly cycle 20.",
"weight": 10
},
{
"criterion": "The response states that the sum of write cycles for all 8 i... | # GOLDEN ANSWER
## Step-by-step Trace
**I1: LOAD F2, 0(R1)** - Issues cycle 1 to Load1. R1 always ready, no data dependency. Cannot execute same cycle as issue (Rule 6), so execution starts cycle 2. Execution latency = 3 cycles: executes cycles 2-4. Writes cycle 5. F2 available from cycle 5 (usable for execution star... |
Algorithms & Data Structures | Construct and analyze the FM-index of a cipher-transformed string.
Original: S = "abracadabra" (length 11)
Cipher at 0-indexed position i, where each character's alphabetic position is p (a=0, b=1, ..., z=25):
- i mod 3 = 0: shift forward by (i mod 5), i.e., new position = (p + (i mod 5)) mod 26
- i mod 3 = 1: shift... | [
{
"criterion": "The response correctly transforms S = 'abracadabra' to produce T' = 'azidczeyyva' (before appending '$'), yielding T = 'azidczeyyva$'.",
"weight": 10
},
{
"criterion": "The response identifies that the characters 'b' and 'r' from S do not appear in the transformed string T'.",
"w... | PHASE 1: CIPHER TRANSFORMATION
Original: S = "abracadabra" (length 11)
Rules:
- i mod 3 = 0: new_p = (p + (i mod 5)) mod 26
- i mod 3 = 1: new_p = (p - ((i*2) mod 4)) mod 26
- i mod 3 = 2: new_p = 25 - p
Character-by-character:
i=0: 'a' (p=0) Rule 0: shift = 0 mod 5 = 0. new_p = (0+0) mod 26 = 0 -> 'a'
i=1: 'b... |
Algorithms & Data Structures | You are given `k` simple undirected graphs `G1..Gk` on the *same* labeled vertex set `V = {1,2,...,n}`.
We say a graph `Q` is a **blow-up pattern** (called a *fun graph*) of a graph `H` if there exists a partition of `V(H)` into `|V(Q)|` nonempty parts, one part per vertex of `Q`, such that:
1. Each part induces eith... | [
{
"criterion": "Does the solution define a Type-A twin pair as a nonedge pair (a,b) with identical open neighborhoods?",
"weight": 10
},
{
"criterion": "Does the solution define a Type-B twin pair as an edge pair (a,b) with identical closed neighborhoods?",
"weight": 10
},
{
"criterion":... | ## Expert Solution (DSA — Graphs / 2-SAT)
### Key structural notion: twins inside `Gi`
Fix one graph `Gi` on vertex set `{1..n}`.
- **Type-A twin pair (open twins):** vertices `a ≠ b` such that
`ab ∉ E(Gi)` and `N(a) = N(b)` (open neighborhoods identical).
- **Type-B twin pair (closed twins):** vertices `a ≠ b`... |
Algorithms & Data Structures | You are given an undirected connected graph G with n vertices and exactly n edges. The graph has no self-loops and no multiple edges. All edges have unit weight. Each edge has a state: **on** or **off**. Initially all edges are **off**.
You are given m queries (v, u). For each query, you must **toggle** (change on to ... | [
{
"criterion": "For the input \"6 3\\n1 2\\n2 3\\n3 4\\n4 1\\n2 5\\n4 6\\n2 4\\n5 6\\n3 1\\n\", does the answer output exactly \"4\\n4\\n2\"?",
"weight": 15
},
{
"criterion": "For the input \"5 4\\n1 2\\n2 3\\n3 1\\n3 4\\n4 5\\n1 2\\n2 3\\n1 3\\n5 1\\n\", does the answer output exactly \"4\\n3\\n3\\... | ## 1) Graph structure
A connected graph with n vertices and n edges contains exactly one simple cycle. All other edges are bridges forming trees attached to cycle vertices.
Let:
- C = set of cycle vertices, k = |C|
- onTreeEdges = number of ON edges not on the cycle
- onCycleEdges = number of ON edges on the cycle
##... |
Machine Learning & Artificial Intelligence | A Deep Belief Network processes 784-dimensional inputs to 10 output classes. The architecture connects Input → L1 → L2 → L3 → Output, where each connection has a weight matrix.\n\n**Configurations:**\n\n| Config | L1 | L2 | L3 | η | k | epochs |\n|--------|-----|-----|-----|------|---|--------|\n| A | 500 | 500 | 500 |... | [
{
"criterion": "The response states that Config K is the optimal valid configuration.",
"weight": 10
},
{
"criterion": "The response states that Config K has Ψ equal to 71.0 or a value between 70.9 and 71.1.",
"weight": 10
},
{
"criterion": "The response derives that M equals 0.002 multi... | Solution: DBN Configuration Optimization
Step 1: Derive the Memory formula
Calculate total parameters P for each calibration config:
- Config A: P = 784×500 + 500×500 + 500×500 + 500×10 = 897,000
- Config B: P = 784×600 + 600×400 + 400×200 + 200×10 = 792,400
- Config D: P = 784×580 + 580×480 + 480×380 + 380×10 = 919,... |
Computer Systems & Operating Systems | System overview
A single-core kernel manages five user processes P1 through P5 over discrete ticks.
At every tick, three subsystems interact: an MLFQ scheduler with three queues and dynamic Q0 quantum, demand-paged virtual memory with TLB and Enhanced Second Chance replacement, and a disk using C-LOOK with anti-starvat... | [
{
"criterion": "Does the answer report cow_faults exactly as 1?",
"weight": 5
},
{
"criterion": "Does the answer report tlb_hits exactly as 1?",
"weight": 5
},
{
"criterion": "Does the answer report p3_first_cow_tick exactly as 16?",
"weight": 10
},
{
"criterion": "Does the a... | # Golden Solution: Single-Core Kernel Simulation (MLFQ + Demand-Paged VM + C-LOOK Disk)
## 1. Setup and Initialization
Physical memory holds 12 frames. Frames F1–F5 are pinned page tables:
| Frame | Role |
|-------|------|
| F1 | PT:P1 |
| F2 | PT:P2 |
| F3 | PT:P4 |
| F4 | PT:P3 (allocated at tick 10) |
| F5 | PT:P... |
Algorithms & Data Structures | You are given a permutation `p` of `{1, 2, ..., n}`. It is **not** sorted in ascending order and **not** sorted in descending order.
Initially, all elements are colored **red**. Players alternate turns. On each turn, a player may do one of:
1. **Rearrange** the permutation so that all **red** elements keep their posi... | [
{
"criterion": "Does the answer state that using the “rearrange while keeping red positions fixed” operation is only useful if it produces an immediate win on that same move (because the opponent can undo any non-winning rearrangement next move)?",
"weight": 10
},
{
"criterion": "Does the answer def... | ### Expert Solution
A “rearrange (keeping red positions fixed)” move is only useful if it produces an **immediate win** on that move; otherwise the opponent can undo any non-winning rearrangement on their next move because the set of fixed (red) positions hasn’t changed.
So the game reduces to a race to recolor enoug... |
Algorithms & Data Structures | Let `a` and `b` be two arrays of lengths `n` and `m`, with no elements in common. Define `merge(a, b)` recursively:
- `merge(∅, b) = b` and `merge(a, ∅) = a`.
- If both are non-empty and `a_1 < b_1`, then
`merge(a, b) = [a_1] + merge([a_2, ..., a_n], b)`.
- If both are non-empty and `a_1 > b_1`, then
`merge(a, b) ... | [
{
"criterion": "Does the answer state that merge outputs the smaller of the two current first elements (a1 vs b1) when both arrays are non-empty?",
"weight": 10
},
{
"criterion": "Does the answer define the block starts as indices i where p[i] is a new prefix maximum (p[i] > all previous p[1..i-1])?... | ### Expert Solution
In `merge(a, b)`, whenever both arrays are non-empty, the next output element is `min(a_1, b_1)`, and that element is removed from its array.
---
## 1) Key lemma (using the maximum)
Let `M` be the **maximum** value among the elements that have not yet been output.
Assume `M` is currently the fir... |
Algorithms & Data Structures | Given integers n, m, and v, consider all n x m matrices whose entries are integers in [1, v].
A matrix a is called **friendly** if:
min_{1 <= i <= n} ( max_{1 <= j <= m} a_{i,j} ) <= max_{1 <= j <= m} ( min_{1 <= i <= n} a_{i,j} )
In words:
- For each row, compute its maximum element. Take the minimum of these r... | [
{
"criterion": "The response outputs 14 as the answer for the test case n=2, m=2, v=2.",
"weight": 10
},
{
"criterion": "The response outputs 11463 as the answer for the test case n=3, m=3, v=3.",
"weight": 10
},
{
"criterion": "The response outputs 123732870 as the answer for the test c... | We count n x m matrices with entries in [1, v] satisfying:
min_i(max_j a[i][j]) <= max_j(min_i a[i][j])
1. Reduction to Equality
Let L = min_i(max_j a[i][j]) achieved at row r1, and
R = max_j(min_i a[i][j]) achieved at column c1.
Consider cell (r1, c1):
- a[r1][c1] <= max_j a[r1][j] = L (since L is the max ... |
Algorithms & Data Structures | ## Reach a Regular Bracket Sequence by Flipping Equal Adjacent Pairs
You are given a bracket string `s` of length `n` consisting only of characters `(` and `)`.
You may apply the following operations any number of times (possibly zero), in any order:
1. Choose an index `i` (`1 ≤ i < n`) such that `s[i] = s[i+1] = '(... | [
{
"criterion": "The answer defines a transformation that flips the bracket character on every even position of the string.",
"weight": 10
},
{
"criterion": "The answer states that in the transformed string the operation can rewrite the substring \\\"()\\\" into \\\")(\\\".",
"weight": 10
},
... | ## Expert Solution
### 1) Key transformation: flip even positions
Define a transformed string `s'` (1-indexed) by flipping the bracket on every even position:
- if `s[i] = '('` then `s'[i] = ')'` for even `i`
- if `s[i] = ')'` then `s'[i] = '('` for even `i`
- odd positions stay unchanged
This transformation is inve... |
Database Systems & Data Engineering | A database system executes concurrent transactions under Snapshot Isolation (SI). The system must detect write-skew anomalies and compute conflict metrics.
CRITICAL CLARIFICATION: All reads occur instantaneously at the transaction's start time (SI snapshot semantics).
Transaction Schedule (10 transactions):
T1: R(X)1... | [
{
"criterion": "Does the answer treat all reads as instantaneous events occurring strictly at start_time(Ti) and not over the transaction’s execution window?",
"weight": 10
},
{
"criterion": "Does the answer conclude Total_WR_Conflicts = 0 by explicitly applying the condition that a WR conflict requ... | ## 1. Conflict Identification (Phase 1)
### 1.1 Write–Read (WR) Conflicts
Under Snapshot Isolation, each transaction reads the most recent committed value strictly before its start time.
For a Write–Read (WR) conflict to exist, there must be a pair (Ti, Tj) such that:
• Ti writes X = v
• Ti commits before start_time... |
Computer Systems & Operating Systems | A processor allows instructions to overlap in execution by using a centralized scoreboarding mechanism rather than strict in-order completion. Execution resources are limited and non-pipelined: there is exactly one Integer execution unit (1-cycle latency), one floating-point unit capable of addition and subtraction (4-... | [
{
"criterion": "Does the answer compute the cycle at which the final instruction finishes committing to be exactly cycle 66?",
"weight": 10
},
{
"criterion": "Does the answer compute the total of all dispatch cycle numbers to be exactly 193?",
"weight": 10
},
{
"criterion": "Does the ans... | Cycle 1:
- I1: Load F3 from the memory location addressed by R3
- Integer unit is free
- I1 dispatches
- End state:
- I1 dispatched
- Integer unit reserved by I1, rest are free
- F3 pending. Other registers unchanged.
Cycle 2:
- I1: Load F3 from the memory location addresse... |
Algorithms & Data Structures | You are given multiple test cases. In each test case, you are given an array `p` of length `n` describing a permutation of `{1,2,…,n}` with missing elements: some `p[i] = -1`, and all non-`-1` values in `p` are **distinct**.
A permutation `b` of length `n` is called a **riffle shuffle** of the sorted permutation `[1,2... | [
{
"criterion": "For a known value v at position i with v<=k, the answer states the exact prefix constraint B[i]=v (i.e., exactly v BLUE positions among indices 1..i).",
"weight": 10
},
{
"criterion": "For a known value v at position i with v>k, the answer states the exact prefix constraint B[i]=i-(v... | Let MOD = 998244353. Precompute factorials `fact[i]` and inverse factorials `invfact[i]` up to the maximum `n` across all test cases, so `C(n,r) = fact[n]*invfact[r]*invfact[n-r] mod MOD`.
Key uniqueness fact (split-point identification):
- For any riffle shuffle permutation `q` that is **not** fully sorted, the split... |
Algorithms & Data Structures | You are given an integer sequence `a = [a1, a2, …, an]`, where each value represents the height of a structure placed in a line.
### Visibility rule (record highs)
Define two collections derived from a sequence `x`:
- **Left-visible heights** `L(x)`: scan `x` from left to right and write down a height whenever it is ... | [
{
"criterion": "Does the answer define L(a) as the record-high values when scanning left to right using a strict 'greater than all previous' rule?",
"weight": 1
},
{
"criterion": "Does the answer state that when processing a non-maximum element x with x <= the last visible value of the current prefi... | ### Overview
We need to count subsequences `a'` whose **left-visible set** and **right-visible set** match those of the original sequence `a`.
Let:
- `L(a)` be the (strictly increasing) sequence of record highs seen from the left.
- `R(a)` be the (strictly increasing, in right-to-left scan order) record highs seen fro... |
Computer Systems & Operating Systems | # Operating Systems / Storage (RAID): Deterministic Layout, Parity Update, Rebuild, and Reliability
## Global constants (used everywhere)
- Disks are named: `D0, D1, D2, D3, D4` (5 disks total).
- Sector size is irrelevant except for parity; for this task **each sector stores exactly 1 byte**.
- A stripe unit (chunk)... | [
{
"criterion": "Line 1 is exactly `RAID5_READ_REQ1: (D0,4,4) (D2,4,4) (D3,4,8) (D4,2,6)`.",
"weight": 10
},
{
"criterion": "Line 2 is exactly `RAID5_READ_REQ2: (D2,3,5) (D3,0,8) (D4,0,5)`.",
"weight": 10
},
{
"criterion": "Line 3 is exactly `WRITE_W_IO_RAID5: reads=5 writes=5`.",
"we... | ### Request R1: read LBAs 14..35 (len=22)
- Stripe 0 covers LBA 0..15. Need LBA 14..15.
- Stripe 0: \(pDisk=0\). For \(p=14,15\Rightarrow j=3\), disk is \(dDisk(3)=(0+1+3)\bmod5=4\Rightarrow D4\).
- Offsets \(o=2,3\) ⇒ D4 sectors 2..3 ⇒ \((D4,2,2)\).
- Stripe 1 covers LBA 16..31. Need entire stripe.
- Stripe 1:... |
Machine Learning & Artificial Intelligence | Output exactly one decimal number with exactly four digits after the decimal point.
Fixed data ($m=2$):
- $x^{(1)}=[1,0]^T,\ y^{(1)}=1$
- $x^{(2)}=[0,1]^T,\ y^{(2)}=0$
Fixed model:
- $b=0,\ w=[2,-2]^T$
- $\sigma(z)=\frac{1}{1+e^{-z}}$
- $z^{(i)}=w^T x^{(i)},\ \hat y^{(i)}=\sigma(z^{(i)})$
For any $\lambda>0$ define
... | [
{
"criterion": "Format: The final answer matches regex ^[0-9]+\\.[0-9]{4}?",
"weight": 10
},
{
"criterion": "Packed signature: $P=8281343$.",
"weight": 10
},
{
"criterion": "Gray transform: $G=4289152$.",
"weight": 10
},
{
"criterion": "Bit reversal: $R=85634$.",
"weight"... | ## Step 1: core scalars
$z^{(1)}=2,\ z^{(2)}=-2$.
Let $a=e^2$. Then
$\hat y^{(1)}=\frac{a}{1+a}$ and $\hat y^{(2)}=\frac{1}{1+a}$, so numerically
$\hat y^{(1)}=0.8807970779778824\ldots$ and $\hat y^{(2)}=0.1192029220221176\ldots$.
Both per-sample losses equal $\ln(1+e^{-2})$, hence
$t=\ln(1+e^{-2})=0.1269280110429725... |
Algorithms & Data Structures | ## Edge-interval cactus counting
You have an undirected graph on `N` vertices with `M` edges in a fixed order `E1..EM`.
A connected component is **cactus-like** if every edge belongs to at most one simple cycle.
The graph is **dune-stable** if each connected component is cactus-like.
Count pairs `(L, R)` with `1 ≤... | [
{
"criterion": "Does the response define a dune-stable graph as one whose every connected component is cactus-like?",
"weight": 10
},
{
"criterion": "Does the response state that dune-stability is preserved under deleting edges?",
"weight": 10
},
{
"criterion": "Does the response state t... | ## Expert solution
**Terminology.** The prompt calls a graph **dune-stable** if every connected component is cactus-like (each edge lies on at most one simple cycle). I will refer to this same property as **desert** below: **desert ⇔ dune-stable**.
### Monotonicity (enables two pointers)
- If a graph is desert (dune... |
Algorithms & Data Structures | ## Scenario
A corridor contains `n` unstable modules placed in a straight line, indexed from `1` to `n`.
Module `i` has an **activation radius** `a[i]`.
You may **manually trigger** a module only if it is still intact. Triggering module `i` instantly destroys every module `j` satisfying:
\[
|i - j| < a[i]
\]
Destr... | [
{
"criterion": "Does the response define the destroyed interval of triggering index i as Li = i - a[i] + 1 and Ri = i + a[i] - 1?",
"weight": 10
},
{
"criterion": "Does the response state that indices with a[i] = 0 cannot be triggered?",
"weight": 10
},
{
"criterion": "Does the response ... | ## Key transformation
Triggering module `i` (only possible when `a[i] > 0`) destroys exactly the interval:
- \(L_i = i - a[i] + 1\)
- \(R_i = i + a[i] - 1\)
So each trigger corresponds to a closed range \([L_i, R_i]\).
The difficulty is that a module cannot be triggered after it has been destroyed, so the final set ... |
Algorithms & Data Structures | ## Problem
There are `n` communication towers (numbered `1..n`) and `m` bidirectional wires.
Tower `i` accepts all integer frequencies in the interval `[l[i], r[i]]` (inclusive).
A tower `b` is called **accessible** from tower `a` if there exists an integer frequency `x` and a sequence of towers
`a = v1, v2, ..., vk... | [
{
"criterion": "The answer explicitly restates that accessibility from tower 1 means: there exists a single integer frequency x such that all towers on the path accept x.",
"weight": 10
},
{
"criterion": "The answer reduces the problem to taking the union over frequencies x of the connected componen... | ### Key reformulation: union over frequencies of the component of tower 1
Fix an integer frequency `x`. Let `Active(x) = { i : l[i] ≤ x ≤ r[i] }`, and consider the subgraph induced by `Active(x)`.
For this `x`, the towers accessible from `1` using frequency `x` are exactly the vertices in the connected component of `1... |
Machine Learning & Artificial Intelligence | Can you prove that, for both (i) learning intervals on [0,1] under the uniform distribution and (ii) learning a linear separator in ℝᵈ under the uniform distribution on the unit sphere, any active learning algorithm requires Ω(d log(1/ε)) label requests to achieve error at most ε with probability ≥ 1/2 — and in particu... | [
{
"criterion": "Does the solution include a formula connecting query complexity k to packing size M (k ≥ log₂ M - 1)?",
"weight": 10
},
{
"criterion": "Does the solution explain that a deterministic algorithm with k queries can produce at most 2ᵏ distinct outputs?",
"weight": 10
},
{
"cr... | ### Theorem
For both settings—(i) learning intervals on $[0,1]$ and (ii) learning linear separators in $\mathbb{R}^d$—there exists a distribution over target functions such that any active learning algorithm (randomized or deterministic) requires $\Omega(d \log(1/\varepsilon))$ label requests to achieve error $\le \var... |
Algorithms & Data Structures | You are given two positive integers **n** and **k**. For every integer **x** such that
1 <= x <= n, write the representation of **x** in base **k** (without leading zeros).
Each representation is a sequence of digits. Collect all n such digit-sequences and sort
them in **lexicographic order**: two sequences are compar... | [
{
"criterion": "The response outputs 4 as the answer for the first test case (n=7, k=2).",
"weight": 10
},
{
"criterion": "The response outputs 1 as the answer for the second test case (n=10, k=3).",
"weight": 10
},
{
"criterion": "The response outputs 11 as the answer for the third test... | PROBLEM ANALYSIS
================
We must count how many x in [1..n] satisfy: lexicographic_rank(x) = x,
where lexicographic_rank(x) is the 1-based position of x's base-k
representation in the sorted array of all representations from 1 to n.
KEY INSIGHT: TRIE MODEL
========================
Model all base-k represent... |
Database Systems & Data Engineering | # Prompt
## Database Storage
### Problem Context and Objective
Consider a B+ tree where each node can hold a maximum of 4 keys and 5 pointers. The tree is initially empty. The following keys are inserted into the tree one at a time, in the order shown:
era, ban, bat, kin, day, log, rye, max, won, ace, ado, bug, cop... | [
{
"criterion": "Does the solution report the utilization after 4 insertions as a = 1.000 (or equivalent rounding)?",
"weight": 10
},
{
"criterion": "Does the solution report the utilization after 8 insertions as b = 0.625?",
"weight": 10
},
{
"criterion": "Does the solution report the ut... | # Golden Answer
## Part 1: B+ Tree Construction
The tree starts empty. Each node can hold at most 4 keys. The split rule for leaves: when a leaf has 5 keys, left gets keys at positions 1-2, right gets keys at positions 3-5, and the key at position 3 (first key of right node) is copied up to the parent.
**Insertions ... |
Algorithms & Data Structures | You are given the following tree-path query problem.
A tree has $n$ nodes numbered from $1$ to $n$. Each node $i$ has an integer value $a_i$.
Each query gives two nodes $x$ and $y$. Let the simple path from $x$ to $y$ be
$$x = p_0,\; p_1,\; p_2,\; \ldots,\; p_r = y$$
Define
$$S = \sum_{k=0}^{r} \bigl(a_{p_k} \oplu... | [
{
"criterion": "Does the answer define b_k(j) as the j-th bit of a_{p_k}, define P_j(k) as the j-th bit of the path index k, and state that the contribution of bit j is 2^j times the sum of b_k(j) XOR P_j(k) over the path positions?",
"weight": 15
},
{
"criterion": "Does the answer define S0, S1, an... | ## Bitwise Decomposition
Let the path for a query be $p_0, p_1, \ldots, p_r$. For each bit position $j \ge 0$, define
$$b_k(j) = ((a_{p_k} \gg j) \mathbin{\&} 1)$$
and
$$P_j(k) = ((k \gg j) \mathbin{\&} 1).$$
Then the $j$-th bit of $a_{p_k} \oplus k$ is
$$b_k(j) \oplus P_j(k).$$
So the contribution of bit $j$ to... |
Computer Systems & Operating Systems | A Count-Min Sketch (CMS) is used to estimate frequencies over a stream of integer keys.
-----------------------------------
SKETCH CONFIGURATION
-----------------------------------
- Depth: d = 4 rows
- Width: w = 11 columns
- Counters are indexed from 0 to 10
- All counters are initialized to 0
- No pre-warm... | [
{
"criterion": "The response states `ignored_updates: 2`.",
"weight": 5
},
{
"criterion": "The response states `hashes_20: 7,8,9,8`.",
"weight": 15
},
{
"criterion": "The response states `counter_1_7: 27`.",
"weight": 10
},
{
"criterion": "The response states `counter_2_8: 27... | Reasoning
Only updates with positive delta are applied. Therefore `(2, -3)` and `(9, -2)` are ignored, so the number of ignored updates is 2.
For the query key `x = 20`, the four hash locations are:
- `g1(20) = (3*20 + 2) mod 11 = 62 mod 11 = 7`
- `g2(20) = (5*20 + 7) mod 11 = 107 mod 11 = 8`
- `g3(20) = (7*20 + 1) ... |
Algorithms & Data Structures | You are given a permutation `p` of size `n` (containing each integer from `1` to `n` exactly once).
For the current permutation, define for each current position `i` (1-indexed):
`c_i = |i - p_i|`
You may repeatedly remove elements from the current permutation. A removal is valid if the chosen element satisfies `c_i... | [
{
"criterion": "States `s=1` as the minimum integer that allows the deterministic process to remove the entire permutation.",
"weight": 20
},
{
"criterion": "States `positions=2,1,2,1,1` exactly.",
"weight": 20
},
{
"criterion": "States `values=1,2,1,2,1` exactly.",
"weight": 15
},... | s=1
positions=2,1,2,1,1
values=1,2,1,2,1
states=[3,1,5,2,4]->[2,4,1,3]->[3,1,2]->[2,1]->[1]->[]
why_s_minus_1_fails=s-1=0 fails because the initial permutation [3,1,5,2,4] has no position with i=p_i, so no element has c_i=0 and the process cannot start.
Reasoning
The key detail is that `c_i` must be recomputed after ... |
Programming Languages, Compilers & Formal Methods | In the secretary problem, an adversary chooses $n$ values $x_1 \ge x_2 \ge \dots \ge x_n$ in $[0,1]$ that arrive online at independent uniform random times in $[0,1]$. An online algorithm must irrevocably select exactly one value upon seeing it (selecting $0$ if none is chosen). The regret of an algorithm on instance $... | [
{
"criterion": "Does the proof explicitly consider the harder variant in which $t_1 \\sim U[0,1]$ is random but the adversary chooses all arrival times $t_2, \\dots, t_n$ in advance?",
"weight": 10
},
{
"criterion": "Does the proof remove every $x_i < f(t_i)$ for $i \\ge 2$ and state that this does ... | Upper bound ($f(t)=1-t$): Consider the harder variant where $t_1 \sim U[0,1]$ but $t_2, \dots, t_n$ are chosen adversarially in advance (any bound here implies the original). Remove every $x_i < f(t_i)$ for $i \ge 2$ (unchanged behavior). Let $j = \arg\min_{i \ge 2} t_i$ (add $x_2=0$ at $t_2=1$ if needed), then keep on... |
Algorithms & Data Structures | ## Problem
Shivam is playing a game with his friends Varad (who controls the doll) and Tanmay.
There are `n` boxes in a line, numbered `1..n`. Varad hides a doll in one box. Shivam will make `m` guesses: on the `i`-th guess Shivam asks whether the doll is currently in box `a[i]`.
Varad can “cheat” by moving the doll... | [
{
"criterion": "The answer states that for each fixed start box x, the set of reachable end boxes y forms a consecutive segment [L[x], R[x]] (except trivial n=1 handling).",
"weight": 10
},
{
"criterion": "The answer states that the final count is computed as the sum over x of the segment lengths (e... | ### 1) Model as reachable positions with “forbidden” points at guess times
Let the doll’s position **before** guess `i` be `pos[i]` (so `pos[1]` is after Varad’s initial move).
Constraints:
- `pos[i] != a[i]` for all `i = 1..m` (otherwise Shivam guesses correctly).
- `pos[i+1]` is obtained from `pos[i]` by a move in `... |
Algorithms & Data Structures | You are given an undirected tree with `n` vertices numbered `1` to `n`. Vertex `i` has an integer value `a_i`.
You may perform the following operation any number of times:
- Choose a vertex with current degree `≤ 1` and delete it (and its incident edge if it exists).
You may delete all vertices.
After deletions, pe... | [
{
"criterion": "Does the answer explicitly state: in the chosen remaining subtree S (before compression), a vertex contributes a_v to the final sum iff deg_S(v) ≠ 2 (and contributes 0 iff deg_S(v)=2 because it is removed during compression)?",
"weight": 20
},
{
"criterion": "Does the answer formally... | ## Expert Solution
Root the tree at node `1`. Any sequence of leaf deletions leaves a connected subtree `S` (possibly empty).
#### Key characterization (compression effect)
Compression repeatedly deletes every vertex of degree exactly `2`. It never deletes vertices of degree `0`, `1`, or `≥ 3`. Hence:
**A vertex `v`... |
Computer Systems & Operating Systems | This problem tests knowledge of operating systems and CPU scheduling. A system implements Multilevel Feedback Queue (MLFQ) scheduling with I/O handling and priority boosting.
SYSTEM CONFIGURATION:
- 3 queues: Q0 (highest priority), Q1 (medium), Q2 (lowest)
- Time quantum: Q0=2ms, Q1=4ms, Q2=8ms
- Higher-priority queue... | [
{
"criterion": "Does the answer state that V1 (P1 completion time) equals exactly 49?",
"weight": 15
},
{
"criterion": "Does the answer state that V2 (total CPU idle time) equals exactly 3?",
"weight": 5
},
{
"criterion": "Does the answer state that V3 (total queue demotions) equals exac... | ## Setup
Queues: Q0 (quantum=2ms, highest), Q1 (quantum=4ms), Q2 (quantum=8ms, lowest).
Priority boost fires at t=20, t=40, ...
All processes including I/O-blocked ones are moved to Q0 on a boost (Rule 7).
Demotion occurs on full quantum exhaustion, even when that coincides with a preemption (Rule 3).
On I/O completio... |
Programming Languages, Compilers & Formal Methods | Simulate Tomasulo's Algorithm with speculative execution for the following instruction sequence.
CONFIGURATION:
Functional Units: 2 Add/Sub (2 cycles), 1 Mul (4 cycles), 1 Div (8 cycles), 1 Load (3 cycles).
Reservation Stations: 3 Add (Add1, Add2, Add3), 2 Mul (Mul1, Mul2), 2 Load (Load1, Load2).
Reorder Buffer: 8 ent... | [
{
"criterion": "Does the answer state that I3 begins execution in exactly cycle 7?",
"weight": 10
},
{
"criterion": "Does the answer state that I5 writes its result in exactly cycle 23?",
"weight": 10
},
{
"criterion": "Does the answer state that the sum of issue cycles for all 12 instru... | TOMASULO'S ALGORITHM EXECUTION TRACE
=== CYCLE-BY-CYCLE EXECUTION ===
CYCLE 1:
- I1 (LOAD F2) ISSUES to Load1, ROB1
- Load1: Busy, Op=Load, Dest=ROB1
- ROB1: Busy, Instr=I1, Dest=F2, Ready=No
CYCLE 2:
- I1 begins EXECUTION (cycles 2-4, 3 cycles for Load)
- I2 (LOAD F4) ISSUES to Load2, ROB2
- Load2: Busy, Op=Load, D... |
Algorithms & Data Structures | You are given a multiset `a` of size `n`: `a_1, a_2, ..., a_n`.
You generate a new multiset `s` as follows:
1. Partition `a` into any number of **non-empty** multisets `x_1, x_2, ..., x_k`, using every element exactly once.
2. For each `x_i`, choose **one of its modes** and insert it into `s`.
A **mode** of a multis... | [
{
"criterion": "Does the answer define cnt[v] as the frequency of value v in the input multiset a?",
"weight": 10
},
{
"criterion": "Does the answer state the feasibility condition for a chosen support T (values appearing at least once in s) as: for every x ∉ T, cnt[x] ≤ sum_{c∈T}?",
"weight": 1... | ### Expert Solution
Let `cnt[v]` be the frequency of value `v` in the input multiset `a`, and let
`M = max_v cnt[v]`
Also let `MOD = 998244353`.
---
## 1) Feasibility condition
Let `T` be the **support** of the output multiset `s` (the set of values that appear at least once in `s`).
For any value `x ∉ T`, we must... |
Algorithms & Data Structures | Ashwini is trapped in a nightmare where Gauss appears and challenges her with a task.
Ram, her friend, explains the rule:
For a given integer **n**, Ashwini must produce a sequence **[a₁, a₂, ..., aₙ]** such that:
1. Each **aᵢ** is between **1** and **10¹⁸**.
2. For every adjacent pair **(aᵢ, aᵢ₊₁)**, the **GCD va... | [
{
"criterion": "Does the answer state the final minimum number of distinct elements as k = 100?",
"weight": 10
},
{
"criterion": "Does the answer explicitly give the maximum sequence length formula for odd k as k(k+1)/2 via Euler tour?",
"weight": 10
},
{
"criterion": "Does the answer ex... | Step 1: Minimum distinct elements (k)
For a set of k distinct numbers, define a complete graph with k vertices and edges labeled by gcd of endpoints.
Each adjacent pair in the sequence corresponds to traversing one edge, and all gcds must be distinct ⇒ no edge may be repeated.
- If k is odd, the complete graph has al... |
Computer Systems & Operating Systems | You are given a distributed system with 4 processes: P0, P1, P2, P3.
Each process maintains a vector clock of size 4.
All clocks are initially: [0,0,0,0]
-----------------------------------
VECTOR CLOCK RULES
-----------------------------------
1. Internal event:
Increment own component.
2. Send event:
Increm... | [
{
"criterion": "Correctly computes E4 = [2,0,1,0]",
"weight": 10
},
{
"criterion": "Correctly computes E9 = [2,3,2,0]",
"weight": 10
},
{
"criterion": "Correctly computes E12 = [3,2,0,3]",
"weight": 10
},
{
"criterion": "Correctly computes E14 = [4,4,2,0]",
"weight": 10
... | [2,0,1,0],[2,3,2,0],[3,2,0,3],[4,4,2,0],[3,2,4,4],67,53,E16,7,3
EXPLANATION
Apply the vector clock rules in order. The complete clock after each event is:
- E1 (P0 internal): [1,0,0,0]
- E2 (P1 internal): [0,1,0,0]
- E3 (P0 sends M1 to P2): [2,0,0,0]
- E4 (P2 receives M1): max([0,0,0,0],[2,0,0,0]) = [2,0,0,0], then ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.