#4880
Se dă o matrice cu \(2\) linii și \(N\) coloane. De asemenea, se dau \(Q\) operații de \(2\) tipuri, pe care va trebui să le procesați în ordine. Cele \(2\) tipuri de operații sunt definite astfel:
Scorul unei submatrice cu colțurile în celulele \((1,st)\), respectiv \((2,dr)\) este calculat astfel:
Definim mediana unui șir de numere \(A\) cu \(M\) elemente, numerotate de la \(1\) la \(M\), ca fiind elementul aflat pe poziția \(\lceil\frac{M}{2} \rceil\) în urma sortării șirului. De exemplu, mediana șirului \([1,3,1,2]\) este \(1\), iar mediana șirului \([1,2,3]\) este \(2\).
Se cere să se determine scorul submatricei date pentru fiecare operație de tip \(2\).
Lot 2025 Baraj 1 Seniori: Problema 2
| Problema | Medwalk | Operații I/O |
tastatură/ecran
|
|---|---|---|---|
| Limita timp | 30 secunde | Limita memorie |
Total: 256 MB
/
Stivă 8 MB
|
| Id soluție | #64701033 | Utilizator | |
| Fișier | medwalk.cpp | Dimensiune | 2.53 KB |
| Data încărcării | 24 Mai 2026, 22:23 | Scor/rezultat | Eroare de compilare |
medwalk.cpp:21:19: error: invalid preprocessing directive #Update 21 | # Update: 1 r c v (1-indexed r, c) | ^~~~~~ medwalk.cpp:32:19: error: invalid preprocessing directive #Query 32 | # Query: 2 l r (1-indexed) | ^~~~~ medwalk.cpp:38:19: error: invalid preprocessing directive #Path 38 | # Path has w+1 cells; median at position floor((w+2)/2) | ^~~~ medwalk.cpp:39:19: error: invalid preprocessing directive #Need 39 | # Need at least M elements <= v for median <= v | ^~~~ medwalk.cpp:45:19: error: invalid preprocessing directive #Binary 45 | # Binary search over sorted unique values in the submatrix | ^~~~~~ medwalk.cpp:49:33: error: stray ‘#’ in program 49 | ans = vals[-1] # worst case: largest value | ^ medwalk.cpp:55:23: error: invalid preprocessing directive #S 55 | # S = # columns with at least one value <= v | ^ medwalk.cpp:56:23: error: invalid preprocessing directive #D 56 | # D = # columns with both values <= v | ^ medwalk.cpp:67:23: error: invalid preprocessing directive #Max 67 | # Max elements <= v in optimal path = S + (1 if D > 0 else 0) | ^~~ medwalk.cpp:68:23: error: invalid preprocessing directive #The 68 | # The extra 1 comes from choosing a "both <= v" column as transition | ^~~ medwalk.cpp:1:1: error: ‘import’ does not name a type 1 | import sys | ^~~~~~ medwalk.cpp:1:1: note: C++20 ‘import’ only available with ‘-fmodules-ts’ medwalk.cpp:7:25: error: ‘idx’ does not name a type 7 | T = int(data[idx]); idx += 1 | ^~~ medwalk.cpp:12:50: error: ‘idx’ does not name a type 12 | N, Q = int(data[idx]), int(data[idx+1]); idx += 2 | ^~~ medwalk.cpp:14:49: error: ‘idx’ does not name a type 14 | row0 = list(map(int, data[idx:idx+N])); idx += N | ^~~ medwalk.cpp:15:49: error: ‘idx’ does not name a type 15 | row1 = list(map(int, data[idx:idx+N])); idx += N | ^~~ medwalk.cpp:18:34: error: ‘idx’ does not name a type 18 | op = int(data[idx]); idx += 1 | ^~~
www.pbinfo.ro permite evaluarea a două tipuri de probleme:
Problema Medwalk face parte din prima categorie. Soluția propusă de tine va fi evaluată astfel:
Suma punctajelor acordate pe testele utilizate pentru verificare este 100. Astfel, soluția ta poate obține cel mult 100 de puncte, caz în care se poate considera corectă.