Task: | Abandoned warehouse |
Sender: | joaquimballester |
Submission time: | 2024-09-09 17:48:43 +0300 |
Language: | C++ (C++11) |
Status: | READY |
Result: | WRONG ANSWER |
test | verdict | time | |
---|---|---|---|
#1 | WRONG ANSWER | 0.00 s | details |
#2 | WRONG ANSWER | 0.00 s | details |
#3 | WRONG ANSWER | 0.00 s | details |
#4 | WRONG ANSWER | 0.00 s | details |
#5 | WRONG ANSWER | 0.00 s | details |
#6 | WRONG ANSWER | 0.06 s | details |
#7 | TIME LIMIT EXCEEDED | -- | details |
#8 | TIME LIMIT EXCEEDED | -- | details |
#9 | TIME LIMIT EXCEEDED | -- | details |
#10 | TIME LIMIT EXCEEDED | -- | details |
#11 | WRONG ANSWER | 0.00 s | details |
#12 | WRONG ANSWER | 0.00 s | details |
#13 | TIME LIMIT EXCEEDED | -- | details |
#14 | WRONG ANSWER | 0.00 s | details |
#15 | WRONG ANSWER | 0.00 s | details |
#16 | TIME LIMIT EXCEEDED | -- | details |
Compiler report
input/code.cpp: In function 'bool dl(Mapa&, int, int)': input/code.cpp:13:32: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<char> >::size_type' {aka 'long unsigned int'} [-Wsign-compare] 13 | return not (x < 0 or x >= m.size() or y < 0 or y >= m[0].size() ); | ~~^~~~~~~~~~~ input/code.cpp:13:58: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare] 13 | return not (x < 0 or x >= m.size() or y < 0 or y >= m[0].size() ); | ~~^~~~~~~~~~~~~~ input/code.cpp: In function 'int found(Mapa&, int, int)': input/code.cpp:17:13: warning: unused variable 'rows' [-Wunused-variable] 17 | int rows = m.size(); | ^~~~ input/code.cpp:18:13: warning: unused variable 'columns' [-Wunused-variable] 18 |...
Code
#include <iostream> #include <vector> #include <queue> #include <string> using namespace std; typedef vector< vector<char> > Mapa; typedef pair<int,int> par; typedef pair<par,int> Coord; #define inf 0x7fffffff bool dl(Mapa& m,int x, int y){ return not (x < 0 or x >= m.size() or y < 0 or y >= m[0].size() ); } int found(Mapa& m,int x,int y){ int rows = m.size(); int columns = m[0].size(); queue<Coord> Q; queue<string> Camins; Camins.push(""); Q.push( Coord(par(x,y),0) ); pair<int, string> ret; ret.first = inf; ret.second = ""; while( not Q.empty() ){ Coord v = Q.front(); string cami = Camins.front(); Camins.pop(); Q.pop(); if(v.second > ret.first) break; if(m[v.first.first][v.first.second] == 'B') if(v.second<ret.first) { ret.first = v.second; ret.second = cami; } m[v.first.first][v.first.second]='#'; int esq = v.first.first-1; int dre = v.first.first+1; int ada = v.first.second-1; int aba = v.first.second+1; if(dl(m,esq,v.first.second) ) if(m[esq][v.first.second]!='#'){ Q.push( Coord( par(esq,v.first.second), v.second+1 ) ); Camins.push(cami+"L"); } if(dl(m,dre,v.first.second) ) if(m[dre][v.first.second]!='#'){ Q.push( Coord( par(dre,v.first.second), v.second+1 ) ); Camins.push(cami+"R"); } if(dl(m,v.first.first,ada) ) if(m[v.first.first][ada]!='#'){ Q.push( Coord( par(v.first.first,ada), v.second+1 ) ); Camins.push(cami+"U"); } if(dl(m,v.first.first,aba) ) if(m[v.first.first][aba]!='#'){ Q.push( Coord( par(v.first.first,aba), v.second+1 ) ); Camins.push(cami+"D"); } } return ret.first; } int main(){ int n,m; int f,c; cin >> n >> m; Mapa mapt(n, vector<char>(m) ); for(int i = 0; i < n ; ++i) for(int j = 0; j < m; ++j){ cin >> mapt[i][j]; if(mapt[i][j] == 'A'){ f = i; c = j; } } int dmin = found(mapt,f,c); if( dmin != inf ) cout << "distancia minima: " << dmin << endl; else cout << "no es pot arribar a cap tresor" << endl; }
Test details
Test 1
Verdict: WRONG ANSWER
input |
---|
10 10 ##.A###### #.##.##.## #####..### .######### ... |
correct output |
---|
NO |
user output |
---|
no es pot arribar a cap tresor |
Test 2
Verdict: WRONG ANSWER
input |
---|
10 10 B#..##.#.. #....A##.. #.....#..# .#......#. ... |
correct output |
---|
NO |
user output |
---|
no es pot arribar a cap tresor |
Test 3
Verdict: WRONG ANSWER
input |
---|
10 10 ...#..A.#. ....B...## ...#...... .......... ... |
correct output |
---|
YES 3 LLD |
user output |
---|
distancia minima: 3 |
Test 4
Verdict: WRONG ANSWER
input |
---|
10 10 .#........ .......... .......... ........#. ... |
correct output |
---|
YES 1 R |
user output |
---|
distancia minima: 1 |
Test 5
Verdict: WRONG ANSWER
input |
---|
10 10 .......... .......... .......... .......... ... |
correct output |
---|
YES 3 RDD |
user output |
---|
distancia minima: 3 |
Test 6
Verdict: WRONG ANSWER
input |
---|
1000 1000 ##.###..######.#########.###.#... |
correct output |
---|
NO |
user output |
---|
no es pot arribar a cap tresor |
Test 7
Verdict: TIME LIMIT EXCEEDED
input |
---|
1000 1000 ####.#.###....#.......##.##.#.... |
correct output |
---|
YES 626 LLLDDRDDDDLDLDDLLLLLDDDDLLDLDL... |
user output |
---|
(empty) |
Test 8
Verdict: TIME LIMIT EXCEEDED
input |
---|
1000 1000 ....#.##......#....#......#...... |
correct output |
---|
YES 364 LULULLULLLULLLLLUULLLLUUULLLLL... |
user output |
---|
(empty) |
Test 9
Verdict: TIME LIMIT EXCEEDED
input |
---|
1000 1000 .................#......#........ |
correct output |
---|
YES 1003 LLLLLLLLLLLLLLLLLLLLLLLLLDLLLL... |
user output |
---|
(empty) |
Test 10
Verdict: TIME LIMIT EXCEEDED
input |
---|
1000 1000 ................................. |
correct output |
---|
YES 947 LLLLLLLLLLLLLLLLLLLLLLLLLLLLLL... |
user output |
---|
(empty) |
Test 11
Verdict: WRONG ANSWER
input |
---|
1000 3 A#B .#. .#. .#. ... |
correct output |
---|
YES 2000 DDDDDDDDDDDDDDDDDDDDDDDDDDDDDD... |
user output |
---|
distancia minima: 2000 |
Test 12
Verdict: WRONG ANSWER
input |
---|
3 1000 A................................ |
correct output |
---|
YES 2000 RRRRRRRRRRRRRRRRRRRRRRRRRRRRRR... |
user output |
---|
distancia minima: 2000 |
Test 13
Verdict: TIME LIMIT EXCEEDED
input |
---|
999 999 A#...#...#...#...#...#...#...#... |
correct output |
---|
YES 499998 DDDDDDDDDDDDDDDDDDDDDDDDDDDDDD... |
user output |
---|
(empty) |
Test 14
Verdict: WRONG ANSWER
input |
---|
1 3 A.B |
correct output |
---|
YES 2 RR |
user output |
---|
distancia minima: 2 |
Test 15
Verdict: WRONG ANSWER
input |
---|
2 2 ## AB |
correct output |
---|
YES 1 R |
user output |
---|
distancia minima: 1 |
Test 16
Verdict: TIME LIMIT EXCEEDED
input |
---|
1000 1000 A................................ |
correct output |
---|
YES 1998 RRRRRRRRRRRRRRRRRRRRRRRRRRRRRR... |
user output |
---|
(empty) |