Task: | Sokkelo |
Sender: | cowperso |
Submission time: | 2022-01-22 13:52:25 +0200 |
Language: | C++ (C++11) |
Status: | READY |
Result: | 0 |
group | verdict | score |
---|---|---|
#1 | WRONG ANSWER | 0 |
#2 | WRONG ANSWER | 0 |
test | verdict | time | group | |
---|---|---|---|---|
#1 | ACCEPTED | 0.01 s | 1, 2 | details |
#2 | ACCEPTED | 0.01 s | 1, 2 | details |
#3 | WRONG ANSWER | 0.01 s | 1, 2 | details |
#4 | ACCEPTED | 0.26 s | 2 | details |
#5 | ACCEPTED | 0.25 s | 2 | details |
#6 | WRONG ANSWER | 0.25 s | 2 | details |
#7 | ACCEPTED | 0.01 s | 1, 2 | details |
#8 | ACCEPTED | 0.27 s | 2 | details |
#9 | ACCEPTED | 0.31 s | 2 | details |
#10 | ACCEPTED | 0.01 s | 1, 2 | details |
#11 | WRONG ANSWER | 0.34 s | 2 | details |
#12 | ACCEPTED | 0.01 s | 1, 2 | details |
#13 | ACCEPTED | 0.25 s | 2 | details |
#14 | ACCEPTED | 0.01 s | 1, 2 | details |
#15 | ACCEPTED | 0.26 s | 2 | details |
#16 | ACCEPTED | 0.01 s | 2 | details |
#17 | ACCEPTED | 0.01 s | 2 | details |
Code
#include <iostream> #include <queue> #include <vector> bool kartta[1000][1000]; int64_t e[1000][1000]; bool z[1000][1000]; uint32_t n, m; std::vector<std::pair<std::pair<uint32_t, uint32_t>, int64_t>> naap(uint32_t y, uint32_t x) { std::vector<std::pair<std::pair<uint32_t, uint32_t>, int64_t>> res = {}; bool tm = kartta[y][x]; if (y != 0) { res.push_back({{y - 1, x}, (tm || kartta[y - 1][x]) * 100000 + 1}); } if (y != n - 1) { res.push_back({{y + 1, x}, (tm || kartta[y + 1][x]) * 100000 + 1}); } if (x != 0) { res.push_back({{y, x - 1}, (tm || kartta[y][x - 1]) * 100000 + 1}); } if (x != m - 1) { res.push_back({{y, x + 1}, (tm || kartta[y][x + 1]) * 100000 + 1}); } return res; } int main() { std::ios::sync_with_stdio(false); std::cin.tie(nullptr); std::cin >> n >> m; uint32_t ax = 0, ay = 0; uint32_t bx = 0, by = 0; for (uint32_t i = 0; i < n; ++i) { for (uint32_t j = 0; j < m; ++j) { char c; std::cin >> c; switch (c) { case '#': kartta[i][j] = true; break; case 'A': ax = j; ay = i; break; case 'B': bx = j; by = i; break; } } } for (uint32_t i = 0; i < n; ++i) { for (uint32_t j = 0; j < m; ++j) { e[i][j] = INT64_C(1) << 60; } } e[ay][ax] = 0; std::priority_queue<std::pair<int64_t, std::pair<uint32_t, uint32_t>>> q = {}; q.push({0, {ay, ax}}); while (!q.empty()) { uint32_t y = q.top().second.first; uint32_t x = q.top().second.second; q.pop(); if (z[y][x]) continue; z[y][x] = true; for (auto b : naap(y, x)) { if (e[y][x] + b.second < e[b.first.first][b.first.second]) { e[b.first.first][b.first.second] = e[y][x] + b.second; q.push({-e[b.first.first][b.first.second], b.first}); } } } if (e[by][bx] >= 100000) { std::cout << e[by][bx] / 100000 << '\n'; } else { std::cout << "1\n"; } }
Test details
Test 1
Group: 1, 2
Verdict: ACCEPTED
input |
---|
20 20 #################### #A.................# #..................# #..................# ... |
correct output |
---|
1 |
user output |
---|
1 |
Test 2
Group: 1, 2
Verdict: ACCEPTED
input |
---|
20 20 #################### #A.................# #..................# #..................# ... |
correct output |
---|
2 |
user output |
---|
2 |
Test 3
Group: 1, 2
Verdict: WRONG ANSWER
input |
---|
20 20 #################### #A.................# #..................# #..................# ... |
correct output |
---|
9 |
user output |
---|
4 |
Test 4
Group: 2
Verdict: ACCEPTED
input |
---|
1000 1000 ##############################... |
correct output |
---|
1 |
user output |
---|
1 |
Test 5
Group: 2
Verdict: ACCEPTED
input |
---|
1000 1000 ##############################... |
correct output |
---|
2 |
user output |
---|
2 |
Test 6
Group: 2
Verdict: WRONG ANSWER
input |
---|
1000 1000 ##############################... |
correct output |
---|
335 |
user output |
---|
4 |
Test 7
Group: 1, 2
Verdict: ACCEPTED
input |
---|
20 20 #################### #####.############## ###.....############ ##.......########### ... |
correct output |
---|
10 |
user output |
---|
10 |
Test 8
Group: 2
Verdict: ACCEPTED
input |
---|
1000 1000 ##############################... |
correct output |
---|
436 |
user output |
---|
436 |
Test 9
Group: 2
Verdict: ACCEPTED
input |
---|
1000 1000 ##############################... |
correct output |
---|
2 |
user output |
---|
2 |
Test 10
Group: 1, 2
Verdict: ACCEPTED
input |
---|
20 20 #################### #B................## #################.## #################.## ... |
correct output |
---|
2 |
user output |
---|
2 |
Test 11
Group: 2
Verdict: WRONG ANSWER
input |
---|
1000 1000 ##############################... |
correct output |
---|
2 |
user output |
---|
3 |
Test 12
Group: 1, 2
Verdict: ACCEPTED
input |
---|
20 20 #################### ##########A######### ##########.######### ##########.######### ... |
correct output |
---|
2 |
user output |
---|
2 |
Test 13
Group: 2
Verdict: ACCEPTED
input |
---|
1000 1000 ##############################... |
correct output |
---|
2 |
user output |
---|
2 |
Test 14
Group: 1, 2
Verdict: ACCEPTED
input |
---|
20 20 #################### ##########A######### ##########.######### ##########.######### ... |
correct output |
---|
12 |
user output |
---|
12 |
Test 15
Group: 2
Verdict: ACCEPTED
input |
---|
1000 1000 ##############################... |
correct output |
---|
502 |
user output |
---|
502 |
Test 16
Group: 2
Verdict: ACCEPTED
input |
---|
3 1000 ##############################... |
correct output |
---|
1 |
user output |
---|
1 |
Test 17
Group: 2
Verdict: ACCEPTED
input |
---|
1000 3 ### #A# #.# #.# ... |
correct output |
---|
1 |
user output |
---|
1 |