#3860
Se dă un șir (a[1], a[2], ..., a[n]) de numere naturale cuprinse între 1 și n. Se dau de asemenea Q interogări, fiecare prin două numere x, y: dacă s-ar ordona a[x], a[x+1], ..., a[y], se obține sau nu o secvență de numere consecutive? (De exemplu, 5,3,6,4 dacă e ordonată se obține 3,4,5,6, care este o secvență de numere consecutive). Dându-se Q întrebări, să se răspundă la acestea. La fiecare interogare, dacă prin sortare se obține o secvență de numere consecutive veți afișa valoarea 1, iar în caz contrar veți afișa valoarea 0.
EJOI 2021, sesiunea de antrenament
| Problema | consecutive1 | Operații I/O |
tastatură/ecran
|
|---|---|---|---|
| Limita timp | 1 secunde | Limita memorie |
Total: 256 MB
/
Stivă 8 MB
|
| Id soluție | #64548405 | Utilizator | |
| Fișier | consecutive1.cpp | Dimensiune | 1.39 KB |
| Data încărcării | 13 Mai 2026, 17:18 | Scor/rezultat | Eroare de compilare |
consecutive1.cpp:8:48: error: ‘int dup [18][100005]’ redeclared as different kind of entity 8 | int mn[LG + 1][N], mx[LG + 1][N], dup[LG + 1][N]; | ^ In file included from /usr/include/x86_64-linux-gnu/bits/sigstksz.h:24, from /usr/include/signal.h:328, from /usr/include/c++/13/csignal:42, from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:116, from consecutive1.cpp:1: /usr/include/unistd.h:552:12: note: previous declaration ‘int dup(int)’ 552 | extern int dup (int __fd) __THROW __wur; | ^~~ consecutive1.cpp: In function ‘int getDup(int, int)’: consecutive1.cpp:23:21: warning: pointer to a function used in arithmetic [-Wpointer-arith] 23 | return max(dup[k][l], dup[k][r - (1 << k) + 1]); | ^ consecutive1.cpp:23:24: warning: pointer to a function used in arithmetic [-Wpointer-arith] 23 | return max(dup[k][l], dup[k][r - (1 << k) + 1]); | ^ consecutive1.cpp:23:32: warning: pointer to a function used in arithmetic [-Wpointer-arith] 23 | return max(dup[k][l], dup[k][r - (1 << k) + 1]); | ^ consecutive1.cpp:23:50: warning: pointer to a function used in arithmetic [-Wpointer-arith] 23 | return max(dup[k][l], dup[k][r - (1 << k) + 1]); | ^ cc1plus: warning: pointer to a function used in arithmetic [-Wpointer-arith] consecutive1.cpp:23:51: error: invalid conversion from ‘int (*)(int)’ to ‘int’ [-fpermissive] 23 | return max(dup[k][l], dup[k][r - (1 << k) + 1]); | ^ | | | int (*)(int) consecutive1.cpp: In function ‘int main()’: consecutive1.cpp:33:14: warning: pointer to a function used in arithmetic [-Wpointer-arith] 33 | dup[0][i] = lastPos[a[i]]; | ^ consecutive1.cpp:33:17: warning: pointer to a function used in arithmetic [-Wpointer-arith] 33 | dup[0][i] = lastPos[a[i]]; | ^ consecutive1.cpp:33:19: error: assignment of read-only location ‘*(dup + ((sizetype)i))’ 33 | dup[0][i] = lastPos[a[i]]; | ~~~~~~~~~~^~~~~~~~~~~~~~~ consecutive1.cpp:48:18: warning: pointer to a function used in arithmetic [-Wpointer-arith] 48 | dup[k][i] = max(dup[k - 1][i], | ^ consecutive1.cpp:48:21: warning: pointer to a function used in arithmetic [-Wpointer-arith] 48 | dup[k][i] = max(dup[k - 1][i], | ^ consecutive1.cpp:48:38: warning: pointer to a function used in arithmetic [-Wpointer-arith] 48 | dup[k][i] = max(dup[k - 1][i], | ^ cc1plus: warning: pointer to a function used in arithmetic [-Wpointer-arith] consecutive1.cpp:48:41: warning: pointer to a function used in arithmetic [-Wpointer-arith] 48 | dup[k][i] = max(dup[k - 1][i], | ^ consecutive1.cpp:49:39: warning: pointer to a function used in arithmetic [-Wpointer-arith] 49 | dup[k - 1][i + (1 << (k - 1))]); | ^ cc1plus: warning: pointer to a function used in arithmetic [-Wpointer-arith] consecutive1.cpp:49:59: warning: pointer to a function used in arithmetic [-Wpointer-arith] 49 | dup[k - 1][i + (1 << (k - 1))]); | ^ consecutive1.cpp:48:23: error: assignment of read-only location ‘*(dup + (((sizetype)k) + ((sizetype)i)))’ 48 | dup[k][i] = max(dup[k - 1][i], | ~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~ 49 | dup[k - 1][i + (1 << (k - 1))]); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
www.pbinfo.ro permite evaluarea a două tipuri de probleme:
Problema consecutive1 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ă.