#3545
John a pornit într-o drumeție. El se află în orașul 1. Se știe efortul pe care îl depune pentru a străbate fiecare oraș, e[i]. De asemenea, se cunoaște și k[i], cu semnificația că orașul i comunică cu orașele care apartin intervalului [max(1, i - k[i]), min(i + k[i], n)]. Observație : Dacă se află în orașul i, acesta poate merge în orașul j doar dacă i comunică cu j și j comunică cu i. Ajutați-l pe John să determine efortul minim pe care trebuie să-l depună pentru a ajunge în orașul n.
| Problema | Drumetie | Operații I/O |
tastatură/ecran
|
|---|---|---|---|
| Limita timp | 0.5 secunde | Limita memorie |
Total: 64 MB
/
Stivă 8 MB
|
| Id soluție | #61787250 | Utilizator | |
| Fișier | drumetie.cpp | Dimensiune | 1.07 KB |
| Data încărcării | 10 Decembrie 2025, 09:45 | Scor/rezultat | Eroare de compilare |
drumetie.cpp:4:23: error: expected initializer before 'dist' typedef unsigned inst dist; const dist dmx = INT64_MAX; ^ drumetie.cpp:4:35: error: 'dist' does not name a type typedef unsigned inst dist; const dist dmx = INT64_MAX; ^ drumetie.cpp:6:1: error: 'dist' does not name a type dist dp[nmx + 2], e[nmx + 2]; ^ drumetie.cpp:10:5: error: 'dist' does not name a type dist val; ^ drumetie.cpp: In member function 'const bool stateMIN::operator<(const stateMIN&) const': drumetie.cpp:11:61: error: 'val' was not declared in this scope const bool operator < (const stateMIN &o) const {return val < o.val;} ^ drumetie.cpp:11:69: error: 'const struct stateMIN' has no member named 'val' const bool operator < (const stateMIN &o) const {return val < o.val;} ^ drumetie.cpp: In function 'int main()': drumetie.cpp:18:9: error: 'dp' was not declared in this scope dp[i] = dmx; ^ drumetie.cpp:18:17: error: 'dmx' was not declared in this scope dp[i] = dmx; ^ drumetie.cpp:19:16: error: 'e' was not declared in this scope cin >> e[i] >> k[i]; ^ drumetie.cpp:21:37: error: 'struct stateMIN' has no member named 'val' tmp.pos = 0, tmp.posmx = 1, tmp.val = 0; ^ drumetie.cpp:26:9: error: 'dist' was not declared in this scope dist dbest = dmx; ^ drumetie.cpp:26:14: error: expected ';' before 'dbest' dist dbest = dmx; ^ drumetie.cpp:27:55: error: 'dbest' was not declared in this scope for(set <stateMIN>::iterator it = pq.begin(); dbest == dmx && it != pq.end(); it++) ^ drumetie.cpp:27:64: error: 'dmx' was not declared in this scope for(set <stateMIN>::iterator it = pq.begin(); dbest == dmx && it != pq.end(); it++) ^ drumetie.cpp:34:30: error: 'const struct stateMIN' has no member named 'val' else dbest = it->val; ^ drumetie.cpp:36:12: error: 'dbest' was not declared in this scope if(dbest < dp[i]) dp[i] = dbest; ^ drumetie.cpp:36:20: error: 'dp' was not declared in this scope if(dbest < dp[i]) dp[i] = dbest; ^ drumetie.cpp:37:48: error: 'struct stateMIN' has no member named 'val' tmp.pos = i; tmp.posmx = i + k[i], tmp.val = dp[i] + e[i]; pq.insert(tmp); ^ drumetie.cpp:37:54: error: 'dp' was not declared in this scope tmp.pos = i; tmp.posmx = i + k[i], tmp.val = dp[i] + e[i]; pq.insert(tmp); ^ drumetie.cpp:37:62: error: 'e' was not declared in this scope tmp.pos = i; tmp.posmx = i + k[i], tmp.val = dp[i] + e[i]; pq.insert(tmp); ^ drumetie.cpp:39:13: error: 'dp' was not declared in this scope cout << dp[n] + e[n] << "\n"; ^ drumetie.cpp:39:21: error: 'e' was not declared in this scope cout << dp[n] + e[n] << "\n"; ^ drumetie.cpp: In member function 'const bool stateMIN::operator<(const stateMIN&) const': drumetie.cpp:11:73: warning: control reaches end of non-void function [-Wreturn-type] const bool operator < (const stateMIN &o) const {return val < o.val;} ^
www.pbinfo.ro permite evaluarea a două tipuri de probleme:
Problema Drumetie 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ă.