All Practice Exams

100+ Free OBI Practice Questions

Prepare for the Olimpíada Brasileira de Informática exam with instant access — no signup required.

✓ No registration✓ No credit card✓ No hidden fees✓ Start practicing immediately
100+ Questions
100% Free

Loading practice questions...

2026 Statistics

Key Facts: OBI Exam

Governing Body

Official Website

Exam Fee

Competition Tracks

Competition Phases

Supported Languages

International Pathway

University Admission

The OBI is Brazil's premier national informatics competition organized by SBC and IC-UNICAMP, fully free of charge across three elimination phases. It tests logical deduction, discrete structures, graph theory, dynamic programming, and computational complexity. This practice bank delivers 100 high-yield multiple-choice questions modeled after official OBI and IOI syllabi.

Sample OBI Practice Questions

Try these sample questions to test your OBI exam readiness. Each question includes a detailed explanation. Start the interactive quiz above for the full 100+ question experience with AI tutoring.

1In competitive programming problems requiring the Next Greater Element (NGE) for every element in an array of size N, which data structure and strategy achieves an optimal overall time complexity of O(N)?
A.A Max-Heap (priority queue) that pops and pushes elements during a nested linear scan of remaining items
B.A balanced Binary Search Tree (such as std::set) storing all elements and querying upper_bound for each element
C.A monotonic decreasing stack that processes array elements from right to left, popping smaller elements before recording the top
D.A Disjoint Set Union (DSU) structure initialized with N singleton sets, performing union operations on adjacent indices
Explanation: A monotonic decreasing stack maintains elements in strictly decreasing order. When traversing the array from right to left, any element on the stack smaller than or equal to the current element cannot be the next greater element for any preceding items and is popped. Because every element is pushed onto and popped from the stack at most once, the total amortized time complexity across all N elements is strictly O(N).
2In a directed graph where every edge weight is either 0 or 1, which algorithm finds the single-source shortest path to all vertices in O(V + E) time without the logarithmic overhead of standard Dijkstra?
A.0-1 BFS using a double-ended queue (std::deque), pushing 0-weight edges to the front and 1-weight edges to the back
B.Standard Breadth-First Search (BFS) using a single FIFO queue, inserting all relaxed vertices at the back regardless of weight
C.Bellman-Ford algorithm executed for exactly 2 full iterations across all edges
D.Floyd-Warshall algorithm restricted to vertices with incident 0-weight edges
Explanation: 0-1 BFS exploits the fact that distances from the source increase by at most 1 along any edge. By using a double-ended queue (deque), vertices relaxed via weight-0 edges are added to the front (`push_front`), while vertices relaxed via weight-1 edges are added to the back (`push_back`). This maintains the invariant that the queue contains elements sorted by tentative distance with at most two distinct distance values (d and d+1), achieving optimal O(V + E) time.
3When implementing a Disjoint Set Union (DSU / Union-Find) data structure with both path compression and union by rank (or size), what is the amortized time complexity per find/union operation?
A.O(1) strictly worst-case time per individual operation
B.O(log N) amortized time per operation
C.O(sqrt(N)) amortized time per operation
D.O(alpha(N)) amortized time per operation, where alpha is the extremely slow-growing inverse Ackermann function
Explanation: Combining path compression (flattening the tree during `find`) with union by rank or size (attaching the shallower/smaller tree under the root of the deeper/larger tree) ensures the tree depth remains virtually constant. Tarjan proved that any sequence of M operations on N elements runs in O(M * alpha(N)) time, where alpha(N) is the inverse Ackermann function. In practice, alpha(N) <= 4 for all conceivable values of N (even up to 10^80), making operations practically instantaneous.
4Which of the following statements is TRUE regarding an in-order traversal (percurso em ordem) of a valid Binary Search Tree (BST) containing distinct integer keys?
A.The traversal visits keys in descending numerical order
B.The traversal visits keys in strictly increasing (ascending) numerical order
C.The traversal visits keys in breadth-first level order from root to leaves
D.The traversal outputs keys in an order that uniquely reconstructs the tree without additional structural information
Explanation: By definition, for any node in a valid Binary Search Tree, all keys in its left subtree are strictly smaller and all keys in its right subtree are strictly larger. An in-order traversal recursively visits the left subtree, processes the current node, and then visits the right subtree. Consequently, the resulting sequence of visited keys is always sorted in strictly ascending numerical order.
5What is the time complexity of building a Binary Heap (Build-Heap) from an arbitrary unsorted array of N elements using Floyd's bottom-up heapify algorithm, compared to inserting elements one by one into an initially empty heap?
A.O(N) for bottom-up Build-Heap, versus O(N log N) for N successive insertions
B.O(N log N) for bottom-up Build-Heap, versus O(N) for N successive insertions
C.O(N log N) for both methods, because every element requires O(log N) comparisons
D.O(N^2) for bottom-up Build-Heap, versus O(N log N) for successive insertions
Explanation: Floyd's bottom-up Build-Heap algorithm runs `siftDown` from index floor(N/2) down to 1. In a heap of height h, there are at most ceil(N / 2^(k+1)) nodes at height k, each requiring at most k operations. The total work is bounded by the convergent series sum_{k=0}^h (k * N / 2^k) = O(N). In contrast, inserting N elements one by one performs `siftUp` on leaves at depth ~log N, which sums to sum_{i=1}^N log(i) = log(N!) = Theta(N log N).
6A standard Segment Tree is constructed over an array of size N to support point updates and range sum queries. What are the space requirement (array size) and time complexity per point update?
A.Array size 2N, point update in O(1) time
B.Array size N log N, point update in O(log N) time
C.Array size up to 4N, point update in O(log N) time
D.Array size N^2, point update in O(N) time
Explanation: A complete binary tree over N leaves has height ceil(log2 N) + 1. When represented as a 1D flat array (with children at 2*p and 2*p + 1), the required array size is bounded by 2^(ceil(log2 N) + 1) - 1 < 4N. A point update modifies a single leaf and traverses upward through its ancestors to the root, updating exactly ceil(log2 N) nodes in O(log N) time.
7Why is Lazy Propagation (propagação preguiçosa) essential when supporting range addition updates on a Segment Tree in competitive programming?
A.It reduces the space complexity of the Segment Tree from O(N) to O(log N)
B.Without lazy propagation, a range update over an interval [L, R] would require visiting every leaf in the range taking O(N log N) worst-case time; lazy propagation defers updates to achieve O(log N) per range update
C.It eliminates the need for recursive function calls by converting the segment tree into a 1D Fenwick tree automatically
D.It allows Segment Trees to support non-associative operations like range median queries in O(1) time
Explanation: In a standard Segment Tree, updating an entire range [L, R] by updating individual elements one by one takes O((R - L + 1) log N) = O(N log N) time. Lazy Propagation stores pending updates in internal nodes representing fully covered canonical segments and propagates them down to children only when those children are visited by subsequent queries or updates. This preserves the O(log N) time guarantee for both range updates and range queries.
8In a 1-indexed Fenwick Tree (Binary Indexed Tree / BIT) of size N, which bitwise expressions are used to update index `i` (adding value `v`) and compute the prefix sum up to index `i`?
A.Update: `i = i >> 1`; Query: `i = i << 1`
B.Update: `i -= (i & -i)`; Query: `i += (i & -i)`
C.Update: `i = (i | (i + 1))`; Query: `i = (i & (i - 1))`
D.Update: `i += (i & -i)`; Query: `i -= (i & -i)`
Explanation: In a 1-indexed Fenwick Tree, the lowest set bit `(i & -i)` determines the range of elements managed by tree index `i`. To update an element, we propagate the change to all responsible parent intervals by repeatedly adding the lowest set bit (`i += (i & -i)`). To query the prefix sum, we accumulate the sum stored at `bit[i]` and strip the lowest set bit (`i -= (i & -i)`) until `i == 0`. Both operations run in O(log N) time.
9A competitive programming problem specifies a graph with V = 100,000 vertices and E = 200,000 directed edges. Why must an Adjacency List be chosen instead of an Adjacency Matrix?
A.An adjacency matrix of size 100,000 x 100,000 would require ~10 GB of RAM, causing Memory Limit Exceeded (MLE), whereas an adjacency list requires only O(V + E) space (~8–12 MB)
B.Adjacency matrices cannot store directed edges or edge weights in standard C++
C.Breadth-First Search (BFS) and Dijkstra's algorithm cannot be executed on an adjacency matrix
D.An adjacency list guarantees O(1) time to check the existence of an edge between any two arbitrary vertices (u, v)
Explanation: An adjacency matrix allocates a 2D array of dimensions V x V. For V = 100,000, allocating `int matrix[100000][100000]` requires 10^10 integers (approx. 40 GB, or 10 GB with 1-byte booleans), vastly exceeding the standard 256 MB or 512 MB memory limits in OBI. An adjacency list uses `std::vector<int> adj[100000]`, consuming O(V + E) space, which requires only a few megabytes.
10Given an unweighted connected graph with V vertices and E edges, what is the time complexity of Breadth-First Search (BFS) to compute the shortest distance (in terms of number of edges) from a single source to all vertices?
A.O(V * log V)
B.O(V^2)
C.O(V + E)
D.O(E * log V)
Explanation: BFS uses a FIFO queue and a visited array. Every vertex is enqueued and dequeued at most once (O(V)), and every edge incident to each vertex is examined exactly once (or twice in undirected graphs) during neighbor iteration (O(E)). Thus, the total time complexity using an adjacency list representation is strictly O(V + E).

About the OBI Exam

The Olimpíada Brasileira de Informática (OBI) is Brazil's official national computer science and informatics competition, organized jointly by the Sociedade Brasileira de Computação (SBC) and the Instituto de Computação da Universidade Estadual de Campinas (IC-UNICAMP). Established in 1999, the OBI stimulates interest in computer science and algorithmic problem-solving among Brazilian youth from primary school through first-year university undergraduate levels. The competition comprises two main modalities: Modalidade Iniciação, which emphasizes computational thinking, discrete logic puzzles, state-machine tracing, and combinatorial invariants on paper without writing code; and Modalidade Programação, which tests competitive programming and software implementation across C, C++, Java, and Python under strict execution time (typically 1.0–2.0 seconds) and memory limits (typically 256–512 MB). The OBI serves as the sole official qualifying pipeline for Brazil's national team at the International Olympiad in Informatics (IOI) and the Ibero-American Competition in Informatics (CIIC). Top performers also qualify for direct university admission through Olympic quota seats (Vagas Olímpicas) at premier Brazilian research universities including UNICAMP, USP, and UNESP. (Note: While official OBI competitions require written logic proofs or source code submissions executed against judge test suites, this 100-question bank serves as an intensive multiple-choice study adaptation covering all core syllabus competencies.)

Assessment

Modalidade Iniciação: 15–20 logic tasks (Levels Júnior, 1, 2). Modalidade Programação: 3–5 coding tasks per phase across 3 progressive phases (Fase 1 Local, Fase 2 Estadual, Fase 3 Nacional). This 100-question study bank covers all 5 primary syllabus categories.

Time Limit

2 to 5 hours per competition phase

Passing Score

Phase cutoff score thresholds established by the OBI Scientific Committee

Exam Fee

Free (Gratuito) (Sociedade Brasileira de Computação (SBC) & IC-UNICAMP)

OBI Exam Content Outline

Not published

Algoritmos e Estruturas de Dados

Core and competitive programming data structures and graph algorithms: arrays, linked lists, stacks, queues, monotonic deques, priority queues (binary heaps), Disjoint Set Union (DSU / Union-Find), Binary Search Trees (BST), Segment Trees (point/range queries and lazy propagation), Fenwick Trees (BIT), Sparse Tables (RMQ), graph representations, BFS, DFS, cycle detection, Topological Sorting, Dijkstra, Bellman-Ford, Floyd-Warshall, Kruskal, Prim, and Articulation Points / Bridges.

Not published

Técnicas de Projeto de Algoritmos

Algorithmic paradigms and problem-solving patterns: Greedy algorithms (greedy-choice property, interval scheduling, fractional knapsack), Dynamic Programming (1D/2D DP, 0/1 knapsack, unbounded knapsack, Longest Common Subsequence, Longest Increasing Subsequence in O(N log N), interval DP, bitmask DP, digit DP, tree DP), Divide and Conquer (Merge Sort, inversion counting, Quickselect), Binary Search on Answers (monotonic feasibility functions), Two Pointers, Sliding Window, Prefix Sums, Difference Arrays, and Backtracking with pruning.

Not published

Análise de Complexidade e Otimização

Asymptotic analysis and computational performance optimization: Big-O, Big-Omega, Big-Theta formal definitions, Master Theorem for divide-and-conquer recurrences, nested loop analysis, harmonic series bounds, space complexity and recursion call stack depth, amortized analysis (vector doubling), and execution time/memory limits on competitive programming judges (10^8 operations/second, 256MB limits, fast I/O in C++).

Not published

Raciocínio Lógico e Iniciação

Foundational discrete logic, computational thinking, and paper-based problem solving: propositional logic, truth tables, contrapositive and negation, invariants and parity arguments, the Pigeonhole Principle (Princípio da Casa dos Pombos), combinatorial games (Nim, subtraction games, Sprague-Grundy theorem), state machine / automaton tracing, flowcharts, variable execution tracing, loop invariants, and puzzle deduction.

Not published

Matemática Computacional e Teoria dos Números

Computational mathematics, number theory, and string algorithms: fast modular exponentiation (binary exponentiation), Euclidean and Extended Euclidean algorithms (GCD, Bézout coefficients, modular inverse), Fermat's Little Theorem, Sieve of Eratosthenes, bitwise tricks and low-bit isolation (LSB), prime factorization, number of divisors, Euler's totient function, Chinese Remainder Theorem, matrix exponentiation for linear recurrences, polynomial rolling hash, and Knuth-Morris-Pratt (KMP).

How to Pass the OBI Exam

What You Need to Know

  • Passing score: Phase cutoff score thresholds established by the OBI Scientific Committee
  • Assessment: Modalidade Iniciação: 15–20 logic tasks (Levels Júnior, 1, 2). Modalidade Programação: 3–5 coding tasks per phase across 3 progressive phases (Fase 1 Local, Fase 2 Estadual, Fase 3 Nacional). This 100-question study bank covers all 5 primary syllabus categories.
  • Time limit: 2 to 5 hours per competition phase
  • Exam fee: Free (Gratuito)

Keys to Passing

  • Work through all 100 available questions
  • Review every answer and explanation
  • Track weak areas and revisit them
  • Use our AI tutor for tough concepts

OBI Study Tips from Top Performers

1Master Asymptotic Time and Memory Complexity: Always analyze the constraints before coding. If N <= 10^5, an O(N log N) or O(N) solution is required; if N <= 20, exponential O(2^N) bitmask DP or backtracking is feasible; if N <= 500, an O(N^3) algorithm like Floyd-Warshall will pass within the 1.0s limit.
2Practice Core Graph Traversals and Shortest Paths: Thoroughly understand BFS for unweighted shortest paths, DFS for topological sorting and cycle detection, Dijkstra with priority_queue for non-negative weighted graphs, and Kruskal with DSU for Minimum Spanning Trees.
3Build Intuition for Dynamic Programming Subproblems: Practice defining clear DP state representations and base cases for knapsack variations, longest increasing subsequence, interval DP, and grid paths. Learn to optimize memory from 2D matrices to 1D rolling arrays.
4Implement Fundamental and Advanced Range Query Structures: Implement Fenwick Trees (Binary Indexed Trees) and Segment Trees from scratch until you can code them fluently in minutes. Understand lazy propagation for range update queries.
5Simulate State Machines and Edge Cases: In Modalidade Iniciação and early Programação problems, trace state transitions with pen and paper. Always test edge cases: empty inputs, single-element arrays, extreme coordinate values, disconnected graphs, and potential 32-bit integer overflow (use 64-bit integers / long long in C++).

Frequently Asked Questions

What is the Olimpíada Brasileira de Informática (OBI) and who organizes it?

The OBI is Brazil's official national informatics and computer science olympiad, organized jointly by the Sociedade Brasileira de Computação (SBC) and the Instituto de Computação da Universidade Estadual de Campinas (IC-UNICAMP). It serves as the primary academic pathway for Brazilian students to excel in computational thinking and qualify for international tournaments like the IOI.

What are the two main modalities of the OBI competition?

The OBI features two modalities: Modalidade Iniciação (Levels Júnior, 1, and 2), which focuses on discrete logic puzzles, computational thinking, and paper-based problem solving without code; and Modalidade Programação (Levels Júnior, 1, 2, and Sênior), where students write code in C, C++, Java, or Python to solve algorithmic challenges evaluated by an automated judge.

How are phases structured and how do participants advance?

The OBI takes place in three progressive phases: Fase 1 (Local / School level), Fase 2 (Estadual / State level), and Fase 3 (Nacional / National Finals). Students who achieve scores above the designated phase cutoffs determined by the OBI Scientific Committee advance to subsequent rounds. Top national medalists are invited to the UNICAMP training camp (Semana Olímpica).

Which programming languages and compilers are supported in Modalidade Programação?

Modalidade Programação supports C, C++ (C++17/C++20), Java, and Python 3. Submissions run inside a sandboxed Linux environment with strict CPU execution time limits (typically 1.0 second) and memory caps (typically 256 MB), where solutions must execute correctly on all hidden test cases to earn full points (0–100 per problem).

How does the OBI connect to the International Olympiad in Informatics (IOI) and university admissions?

The top-performing high school students in Modalidade Programação Nível 2 are invited to intensive training courses at UNICAMP. From this pool, the four-member Brazilian National Team is selected to represent Brazil at the IOI and CIIC. Furthermore, OBI medalists can gain direct admission to leading Brazilian universities (such as UNICAMP, USP, and UNESP) via Olympic quota admission systems (Vagas Olímpicas) without sitting for traditional entrance exams (Vestibular).

Is there any registration or participation fee for the OBI?

No. The Olimpíada Brasileira de Informática is 100% free of charge (Gratuito) for all participating primary, secondary, and higher-education schools and students across Brazil, supported by public academic institutions and sponsor partnerships.