Task: | Abandoned warehouse |
Sender: | Rasse |
Submission time: | 2024-09-09 17:27:30 +0300 |
Language: | C++ (C++11) |
Status: | READY |
Result: | WRONG ANSWER |
test | verdict | time | |
---|---|---|---|
#1 | ACCEPTED | 0.00 s | details |
#2 | ACCEPTED | 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 | ACCEPTED | 0.03 s | details |
#7 | WRONG ANSWER | 0.05 s | details |
#8 | WRONG ANSWER | 0.05 s | details |
#9 | WRONG ANSWER | 0.05 s | details |
#10 | WRONG ANSWER | 0.04 s | details |
#11 | WRONG ANSWER | 0.00 s | details |
#12 | WRONG ANSWER | 0.00 s | details |
#13 | WRONG ANSWER | 0.06 s | details |
#14 | WRONG ANSWER | 0.00 s | details |
#15 | WRONG ANSWER | 0.00 s | details |
#16 | WRONG ANSWER | 0.04 s | details |
Compiler report
input/code.cpp: In function 'int main()': input/code.cpp:57:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare] 57 | if (x < map[y].size() - 1 && (map[y][x+1] == '.' || map[y][x+1] == 'A')) | ~~^~~~~~~~~~~~~~~~~~~ input/code.cpp:63:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<char> >::size_type' {aka 'long unsigned int'} [-Wsign-compare] 63 | if (y < map.size() - 1 && (map[y+1][x] == '.' || map[y+1][x] == 'A')) | ~~^~~~~~~~~~~~~~~~ input/code.cpp:79:26: warning: 'endX' may be used uninitialized in this function [-Wmaybe-uninitialized] 79 | while (x != endX || y != endY) | ~~~~~~~~~~^~~~~~~~~~~~ input/code.cpp:70:27: warning: 'startX' may be used uninitialized in this function [-Wmaybe-uninitialized] 70 | if (map[startY][startX]...
Code
// Online C++ compiler to run C++ program online #include <iostream> #include <algorithm> #include <vector> #include <queue> using namespace std; int main() { // Write C++ code here int n, m; // height, width std::cin >> n >> m; vector<vector<char>> map = vector<vector<char>>(n, vector<char>(m, 0)); int startX, startY = 0; int endX, endY = 0; for (int y = 0; y < n; y++) { string line; std::cin >> line; for (int x = 0; x < m; x++) { map[y][x] = line[x]; if (line[x] == 'A') { startX = x; startY = y; } else if (line[x] == 'B') { endX = x; endY = y; } } } queue<pair<int, int>> que = queue<pair<int, int>>(); que.push({endX, endY}); while (!que.empty()) { pair<int, int> coord = que.front(); que.pop(); int y = coord.second; int x = coord.first; if (y > 0 && (map[y-1][x] == '.' || map[y-1][x] == 'A')) { map[y-1][x] = 'D'; que.push({x, y-1}); } if (x > 0 && (map[y][x-1] == '.' || map[y][x-1] == 'A')) { map[y][x-1] = 'R'; que.push({x-1, y}); } if (x < map[y].size() - 1 && (map[y][x+1] == '.' || map[y][x+1] == 'A')) { map[y][x + 1] = 'L'; que.push({x+1, y}); } if (y < map.size() - 1 && (map[y+1][x] == '.' || map[y+1][x] == 'A')) { map[y+1][x] = 'U'; que.push({x, y+1}); } } if (map[startY][startX] == 'A') { std::cout << "NO"; } else { std::cout << "YES" << std::endl; int x = startX; int y = startY; while (x != endX || y != endY) { std::cout << (char)map[y][x]; if (map[y][x] == 'L') x--; else if (map[y][x] == 'U') y--; else if (map[y][x] == 'R') x++; else if (map[y][x] == 'D') y++; } } /* cout << endl; for (int y = 0; y < n; y++) { for (int x = 0; x < m; x++) std::cout << map[y][x]; std::cout << endl; } */ return 0; }
Test details
Test 1
Verdict: ACCEPTED
input |
---|
10 10 ##.A###### #.##.##.## #####..### .######### ... |
correct output |
---|
NO |
user output |
---|
NO |
Test 2
Verdict: ACCEPTED
input |
---|
10 10 B#..##.#.. #....A##.. #.....#..# .#......#. ... |
correct output |
---|
NO |
user output |
---|
NO |
Test 3
Verdict: WRONG ANSWER
input |
---|
10 10 ...#..A.#. ....B...## ...#...... .......... ... |
correct output |
---|
YES 3 LLD |
user output |
---|
YES LLD |
Test 4
Verdict: WRONG ANSWER
input |
---|
10 10 .#........ .......... .......... ........#. ... |
correct output |
---|
YES 1 R |
user output |
---|
YES R |
Test 5
Verdict: WRONG ANSWER
input |
---|
10 10 .......... .......... .......... .......... ... |
correct output |
---|
YES 3 RDD |
user output |
---|
YES RDD |
Test 6
Verdict: ACCEPTED
input |
---|
1000 1000 ##.###..######.#########.###.#... |
correct output |
---|
NO |
user output |
---|
NO |
Test 7
Verdict: WRONG ANSWER
input |
---|
1000 1000 ####.#.###....#.......##.##.#.... |
correct output |
---|
YES 626 LLLDDRDDDDLDLDDLLLLLDDDDLLDLDL... |
user output |
---|
YES LLLDDRDDDDLDLDDLLLLLDDDDLLDLDL... Truncated |
Test 8
Verdict: WRONG ANSWER
input |
---|
1000 1000 ....#.##......#....#......#...... |
correct output |
---|
YES 364 LULULLULLLULLLLLUULLLLUUULLLLL... |
user output |
---|
YES UUUUUULUUUUUUUUUUULLLUUUULLUUU... Truncated |
Test 9
Verdict: WRONG ANSWER
input |
---|
1000 1000 .................#......#........ |
correct output |
---|
YES 1003 LLLLLLLLLLLLLLLLLLLLLLLLLDLLLL... |
user output |
---|
YES LLLLLLLLLLLLLLLLLLLLLLLLLDLLLL... Truncated |
Test 10
Verdict: WRONG ANSWER
input |
---|
1000 1000 ................................. |
correct output |
---|
YES 947 LLLLLLLLLLLLLLLLLLLLLLLLLLLLLL... |
user output |
---|
YES UUUUUUUUUUUUUUUUUUUUUUUUUUUUUU... Truncated |
Test 11
Verdict: WRONG ANSWER
input |
---|
1000 3 A#B .#. .#. .#. ... |
correct output |
---|
YES 2000 DDDDDDDDDDDDDDDDDDDDDDDDDDDDDD... |
user output |
---|
YES DDDDDDDDDDDDDDDDDDDDDDDDDDDDDD... Truncated |
Test 12
Verdict: WRONG ANSWER
input |
---|
3 1000 A................................ |
correct output |
---|
YES 2000 RRRRRRRRRRRRRRRRRRRRRRRRRRRRRR... |
user output |
---|
YES RRRRRRRRRRRRRRRRRRRRRRRRRRRRRR... Truncated |
Test 13
Verdict: WRONG ANSWER
input |
---|
999 999 A#...#...#...#...#...#...#...#... |
correct output |
---|
YES 499998 DDDDDDDDDDDDDDDDDDDDDDDDDDDDDD... |
user output |
---|
YES DDDDDDDDDDDDDDDDDDDDDDDDDDDDDD... Truncated |
Test 14
Verdict: WRONG ANSWER
input |
---|
1 3 A.B |
correct output |
---|
YES 2 RR |
user output |
---|
YES RR |
Test 15
Verdict: WRONG ANSWER
input |
---|
2 2 ## AB |
correct output |
---|
YES 1 R |
user output |
---|
YES R |
Test 16
Verdict: WRONG ANSWER
input |
---|
1000 1000 A................................ |
correct output |
---|
YES 1998 RRRRRRRRRRRRRRRRRRRRRRRRRRRRRR... |
user output |
---|
YES RRRRRRRRRRRRRRRRRRRRRRRRRRRRRR... Truncated |