#4607
Astar
Se dă o hartă de NxN
care conține spații libere (notate cu '.'
) și spații ocupate (notate cu '#'
). Să se răspundă la Q
interogări de forma i1 j1 i2 j2
, unde se dorește să se afle distanța minimă de la celula (i1, j1)
la celula (i2, j2)
.
Problema | Astar | Operații I/O | tastatură/ecran |
---|---|---|---|
Limita timp | 3.5 secunde | Limita memorie |
Total: 64 MB
/
Stivă 8 MB
|
Id soluție | #52336056 | Utilizator | |
Fișier | astar.cpp | Dimensiune | 1.63 KB |
Data încărcării | 26 Septembrie 2024, 18:31 | Scor / rezultat | Eroare de compilare |
astar.cpp:8:1: error: stray '\342' in program int getCost(celula a, celula b){ return (a.x – b.x) * (a.x – b.x) + (a.y – b.y) * (a.y – b.y); } ^ astar.cpp:8:1: error: stray '\200' in program astar.cpp:8:1: error: stray '\223' in program astar.cpp:8:1: error: stray '\342' in program astar.cpp:8:1: error: stray '\200' in program astar.cpp:8:1: error: stray '\223' in program astar.cpp:8:1: error: stray '\342' in program astar.cpp:8:1: error: stray '\200' in program astar.cpp:8:1: error: stray '\223' in program astar.cpp:8:1: error: stray '\342' in program astar.cpp:8:1: error: stray '\200' in program astar.cpp:8:1: error: stray '\223' in program astar.cpp:19:1: error: stray '\342' in program int main(){ ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL); cin>>n; for(int i = 1; i <= n; i++){ for(int j = 1; j <= n; j++) cin>>chr, lee[i][j] = ((chr '#') ? -1 : (1 << 30)); } cin>>queries; for(int t = 1; t <= queries; t++){ cin>>startt.x>>startt.y>>endd.x>>endd.y; startt.x++; startt.y++; endd.x++; endd.y++; if(lee[startt.x][startt.y] -1 || lee[endd.x][endd.y] -1){ cout<<-1<<"\n"; continue; } startt.cost = getCost(startt, endd); endd.cost = getCost(endd, endd); for(int i = 1; i <= n; i++){ for(int j = 1; j <= n; j++) lee[i][j] = ((lee[i][j] -1) ? -1 : (1 << 30)); } lee[startt.x][startt.y] = 0; genLee(startt); if(lee[endd.x][endd.y] == (1 << 30)) cout<<-1<<”\n”; else cout<<lee[endd.x][endd.y]<<”\n”; } return 0; } ^ astar.cpp:19:1: error: stray '\200' in program astar.cpp:19:1: error: stray '\235' in program astar.cpp:19:1: error: stray '\' in program astar.cpp:19:1: error: stray '\342' in program astar.cpp:19:1: error: stray '\200' in program astar.cpp:19:1: error: stray '\235' in program astar.cpp:19:1: error: stray '\342' in program astar.cpp:19:1: error: stray '\200' in program astar.cpp:19:1: error: stray '\235' in program astar.cpp:19:1: error: stray '\' in program astar.cpp:19:1: error: stray '\342' in program astar.cpp:19:1: error: stray '\200' in program astar.cpp:19:1: error: stray '\235' in program astar.cpp: In function 'int getCost(celula, celula)': astar.cpp:8:50: error: expected ')' before 'b' int getCost(celula a, celula b){ return (a.x – b.x) * (a.x – b.x) + (a.y – b.y) * (a.y – b.y); } ^ astar.cpp: In function 'int main()': astar.cpp:19:167: error: expected ')' before '#' int main(){ ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL); cin>>n; for(int i = 1; i <= n; i++){ for(int j = 1; j <= n; j++) cin>>chr, lee[i][j] = ((chr '#') ? -1 : (1 << 30)); } cin>>queries; for(int t = 1; t <= queries; t++){ cin>>startt.x>>startt.y>>endd.x>>endd.y; startt.x++; startt.y++; endd.x++; endd.y++; if(lee[startt.x][startt.y] -1 || lee[endd.x][endd.y] -1){ cout<<-1<<"\n"; continue; } startt.cost = getCost(startt, endd); endd.cost = getCost(endd, endd); for(int i = 1; i <= n; i++){ for(int j = 1; j <= n; j++) lee[i][j] = ((lee[i][j] -1) ? -1 : (1 << 30)); } lee[startt.x][startt.y] = 0; genLee(startt); if(lee[endd.x][endd.y] == (1 << 30)) cout<<-1<<”\n”; else cout<<lee[endd.x][endd.y]<<”\n”; } return 0; } ^ astar.cpp:19:189: error: expected ')' before ';' token int main(){ ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL); cin>>n; for(int i = 1; i <= n; i++){ for(int j = 1; j <= n; j++) cin>>chr, lee[i][j] = ((chr '#') ? -1 : (1 << 30)); } cin>>queries; for(int t = 1; t <= queries; t++){ cin>>startt.x>>startt.y>>endd.x>>endd.y; startt.x++; startt.y++; endd.x++; endd.y++; if(lee[startt.x][startt.y] -1 || lee[endd.x][endd.y] -1){ cout<<-1<<"\n"; continue; } startt.cost = getCost(startt, endd); endd.cost = getCost(endd, endd); for(int i = 1; i <= n; i++){ for(int j = 1; j <= n; j++) lee[i][j] = ((lee[i][j] -1) ? -1 : (1 << 30)); } lee[startt.x][startt.y] = 0; genLee(startt); if(lee[endd.x][endd.y] == (1 << 30)) cout<<-1<<”\n”; else cout<<lee[endd.x][endd.y]<<”\n”; } return 0; } ^
www.pbinfo.ro permite evaluarea a două tipuri de probleme:
Problema Astar 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ă.