#1203
Fie un vector V cu N elemente și un număr K. Vectorul V trebuie împărțit în exact K subsecvențe nevide, astfel încât fiecare element din vector să aparțină exact unei subsecvențe. Această împărțire trebuie făcută astfel încât maximul șmecheriei fiecărei subsecvențe să fie cât mai mic. (Această problemă concepe greșit sistemul de șmecherie și valoare). Șmecheria fiecărei subsecvențe se definește ca fiind parte întreagă din ((Vmax – Vmin + 1) / 2), unde Vmax este valoarea maximă din subsecvență, iar Vmin este valoarea minimă.
Vectorul V de N elemente va fi generat în felul următor: se dă un număr M și 2 vectori A și B de lungime M (indexați de la 0 la M - 1). Fiecare element i, 0 ≤ i < N, din vectorul V va fi calculat cu următoarea formulă: V[i] = (A[i % M] ^ B[i / M]), unde x % y reprezintă restul lui x la împărțirea cu y, x / y reprezintă câtul împărțirii lui x la y și x ^ y reprezintă rezultatul operației xor (sau exclusiv pe biți) dintre x și y.
ONI 2015, Clasele XI-XII
| Problema | KSecv | Operații I/O |
ksecv.in/ksecv.out
|
|---|---|---|---|
| Limita timp | 0.2 secunde | Limita memorie |
Total: 128 MB
/
Stivă 16 MB
|
| Id soluție | #58915394 | Utilizator | |
| Fișier | ksecv.cpp | Dimensiune | 7.01 KB |
| Data încărcării | 02 Septembrie 2025, 18:55 | Scor/rezultat | Eroare de compilare |
ksecv.cpp:169:2: error: stray '#' in program }#pragma GCC optimize("O3,unroll-loops") ^ ksecv.cpp: In function 'int try_solve(int64_t)': ksecv.cpp:101:11: warning: unused variable 'min' [-Wunused-variable] int64_t min = arr[pos]; ^ ksecv.cpp:102:11: warning: unused variable 'max' [-Wunused-variable] int64_t max = arr[pos]; ^ ksecv.cpp:106:7: warning: unused variable 'le' [-Wunused-variable] int le = pos; ^ ksecv.cpp:115:9: error: expected unqualified-id before '[' token auto& [node, old_min, old_max] = op_stk[op_stk_sz-1]; ^ ksecv.cpp:115:9: error: expected initializer before '[' token ksecv.cpp:118:12: error: 'node' was not declared in this scope disabled[node] = 0; ^ ksecv.cpp:119:20: error: 'old_min' was not declared in this scope tree_min[node] = old_min; ^ ksecv.cpp:120:20: error: 'old_max' was not declared in this scope tree_max[node] = old_max; ^ ksecv.cpp: In lambda function: ksecv.cpp:153:7: warning: unused variable 'it' [-Wunused-variable] int it = 0; ^ ksecv.cpp: At global scope: ksecv.cpp:169:3: error: 'pragma' does not name a type }#pragma GCC optimize("O3,unroll-loops") ^ ksecv.cpp:189:20: error: redefinition of 'int64_t arr [1000001]' int64_t arr[1000001]; ^ ksecv.cpp:18:9: error: 'int64_t arr [1000001]' previously declared here int64_t arr[1000001]; ^ ksecv.cpp:190:19: error: redefinition of 'int64_t arr_a [2048]' int64_t arr_a[2048]; ^ ksecv.cpp:19:9: error: 'int64_t arr_a [2048]' previously declared here int64_t arr_a[2048]; ^ ksecv.cpp:191:19: error: redefinition of 'int64_t arr_b [2048]' int64_t arr_b[2048]; ^ ksecv.cpp:20:9: error: 'int64_t arr_b [2048]' previously declared here int64_t arr_b[2048]; ^ ksecv.cpp:193:25: error: redefinition of 'int64_t tree_min [4000025]' int64_t tree_min[4000025]; ^ ksecv.cpp:22:9: error: 'int64_t tree_min [4000025]' previously declared here int64_t tree_min[4000025]; ^ ksecv.cpp:194:25: error: redefinition of 'int64_t tree_max [4000025]' int64_t tree_max[4000025]; ^ ksecv.cpp:23:9: error: 'int64_t tree_max [4000025]' previously declared here int64_t tree_max[4000025]; ^ ksecv.cpp:195:22: error: redefinition of 'bool disabled [4000025]' bool disabled[4000025]; ^ ksecv.cpp:24:6: error: 'bool disabled [4000025]' previously declared here bool disabled[4000025]; ^ ksecv.cpp:197:5: error: redefinition of 'int op_stk_sz' int op_stk_sz; ^ ksecv.cpp:26:5: error: 'int op_stk_sz' previously declared here int op_stk_sz; ^ ksecv.cpp:198:46: error: redefinition of 'std::tuple<int, long long int, long long int> op_stk [200005]' std::tuple<int,int64_t,int64_t> op_stk[200005]; ^ ksecv.cpp:27:33: error: 'std::tuple<int, long long int, long long int> op_stk [200005]' previously declared here std::tuple<int,int64_t,int64_t> op_stk[200005]; ^ ksecv.cpp: In function 'void build_tree(int, int, int)': ksecv.cpp:200:6: error: redefinition of 'void build_tree(int, int, int)' void build_tree(int node, int l, int r) { ^ ksecv.cpp:29:6: error: 'void build_tree(int, int, int)' previously defined here void build_tree(int node, int l, int r) { ^ ksecv.cpp: At global scope: ksecv.cpp:219:9: error: redefinition of 'int64_t curr_max' int64_t curr_max; ^ ksecv.cpp:48:9: error: 'int64_t curr_max' previously declared here int64_t curr_max; ^ ksecv.cpp:220:9: error: redefinition of 'int64_t curr_min' int64_t curr_min; ^ ksecv.cpp:49:9: error: 'int64_t curr_min' previously declared here int64_t curr_min; ^ ksecv.cpp: In function 'int segtree_walk(int, int, int, int64_t)': ksecv.cpp:221:5: error: redefinition of 'int segtree_walk(int, int, int, int64_t)' int segtree_walk(int node, int l, int r, int64_t cap) { ^ ksecv.cpp:50:5: error: 'int segtree_walk(int, int, int, int64_t)' previously defined here int segtree_walk(int node, int l, int r, int64_t cap) { ^ ksecv.cpp: In function 'void segtree_disable(int, int, int, int, int)': ksecv.cpp:238:6: error: redefinition of 'void segtree_disable(int, int, int, int, int)' void segtree_disable(int node, int l, int r, int st, int fi) { ^ ksecv.cpp:67:6: error: 'void segtree_disable(int, int, int, int, int)' previously defined here void segtree_disable(int node, int l, int r, int st, int fi) { ^ ksecv.cpp: In function 'int try_solve(int64_t)': ksecv.cpp:263:5: error: redefinition of 'int try_solve(int64_t)' int try_solve(int64_t cap) { ^ ksecv.cpp:92:5: error: 'int try_solve(int64_t)' previously defined here int try_solve(int64_t cap) { ^ ksecv.cpp:272:11: warning: unused variable 'min' [-Wunused-variable] int64_t min = arr[pos]; ^ ksecv.cpp:273:11: warning: unused variable 'max' [-Wunused-variable] int64_t max = arr[pos]; ^ ksecv.cpp:277:7: warning: unused variable 'le' [-Wunused-variable] int le = pos; ^ ksecv.cpp:286:9: error: expected unqualified-id before '[' token auto& [node, old_min, old_max] = op_stk[op_stk_sz-1]; ^ ksecv.cpp:286:9: error: expected initializer before '[' token ksecv.cpp:289:12: error: 'node' was not declared in this scope disabled[node] = 0; ^ ksecv.cpp:290:20: error: 'old_min' was not declared in this scope tree_min[node] = old_min; ^ ksecv.cpp:291:20: error: 'old_max' was not declared in this scope tree_max[node] = old_max; ^ ksecv.cpp: In function 'int main()': ksecv.cpp:304:5: error: redefinition of 'int main()' int main() { ^ ksecv.cpp:133:5: error: 'int main()' previously defined here int main() { ^ ksecv.cpp: In lambda function: ksecv.cpp:324:7: warning: unused variable 'it' [-Wunused-variable] int it = 0; ^
www.pbinfo.ro permite evaluarea a două tipuri de probleme:
Problema KSecv 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ă.