| Task: | Elegant Showroom |
| Sender: | #dt-lapset |
| Submission time: | 2016-11-12 13:38:45 +0200 |
| Language: | C++ |
| Status: | READY |
| Result: | WRONG ANSWER |
| test | verdict | time | |
|---|---|---|---|
| #1 | WRONG ANSWER | 0.06 s | details |
| #2 | WRONG ANSWER | 0.06 s | details |
| #3 | WRONG ANSWER | 0.06 s | details |
| #4 | WRONG ANSWER | 0.09 s | details |
| #5 | WRONG ANSWER | 0.10 s | details |
| #6 | WRONG ANSWER | 0.09 s | details |
| #7 | WRONG ANSWER | 0.07 s | details |
| #8 | WRONG ANSWER | 0.12 s | details |
| #9 | WRONG ANSWER | 0.05 s | details |
| #10 | WRONG ANSWER | 0.05 s | details |
| #11 | WRONG ANSWER | 0.06 s | details |
| #12 | WRONG ANSWER | 0.05 s | details |
| #13 | WRONG ANSWER | 0.06 s | details |
| #14 | ACCEPTED | 0.06 s | details |
| #15 | ACCEPTED | 0.05 s | details |
| #16 | ACCEPTED | 0.05 s | details |
Code
#include <bits/stdc++.h>
#define INF 999999999
#define F first
#define S second
using namespace std;
char c[444][444];
int d[444][444];
bool b[444][444];
int main () {
int n, m;
cin>>n>>m;
for (int y = 1; y <= n; y++) {
for (int x = 1 ; x <= m; x++) cin>>c[y][x];
}
for (int y = 0; y <= n + 1; y++) {
for (int x = 0 ; x <= m + 1; x++) d[y][x] = INF;
}
int x, y;
cin>>y>>x;
priority_queue<pair<int, pair<int, int>>> q;
q.push({0, {y, x}});
d[y][x] = 0;
while (!q.empty()) {
int y = q.top().S.F;
int x = q.top().S.S;
int e = q.top().F;
q.pop();
if (!y || !x || x == m + 1 || y == n + 1) continue;
if (c[y][x] == '#') continue;
if (b[y][x]) continue;
b[y][x] = 1;
if (d[y][x + 1] > e + (c[y][x + 1] == 'c')) d[y][x + 1] = e + (c[y][x + 1] == 'c'), q.push({e + (c[y][x + 1] == 'c'), {y, x + 1}});
if (d[y][x - 1] > e + (c[y][x - 1] == 'c')) d[y][x - 1] = e + (c[y][x - 1] == 'c'), q.push({e + (c[y][x - 1] == 'c'), {y, x - 1}});
if (d[y + 1][x] > e + (c[y + 1][x] == 'c')) d[y + 1][x] = e + (c[y + 1][x] == 'c'), q.push({e + (c[y + 1][x] == 'c'), {y + 1, x}});
if (d[y - 1][x] > e + (c[y - 1][x] == 'c')) d[y - 1][x] = e + (c[y - 1][x] == 'c'), q.push({e + (c[y - 1][x] == 'c'), {y - 1, x}});
}
int ans = INF;
for (int y = 1; y <= n; y++) {
if (c[y][1] == 'D') ans = min(ans, d[y][1]);
if (c[y][m] == 'D') ans = min(ans, d[y][m]);
}
for (int y = 1; y <= m; y++) {
if (c[1][x] == 'D') ans = min(ans, d[1][x]);
if (c[n][x] == 'D') ans = min(ans, d[n][x]);
}
cout<<ans + (c[y][x] == 'c')<<endl;
}Test details
Test 1
Verdict: WRONG ANSWER
| input |
|---|
| 20 20 DDDDDDDDDDD##DD#DD#D DDccccc#c##c##cDccDD Dc#c#c#cc#ccc#c#Dc#D DccDc#Dc####ccc#c#DD ... |
| correct output |
|---|
| 3 |
| user output |
|---|
| 7 |
Test 2
Verdict: WRONG ANSWER
| input |
|---|
| 20 20 #################### #cccccccccccccccccc# #c################c# #c#cccccccccccccc#c# ... |
| correct output |
|---|
| 179 |
| user output |
|---|
| 1000000000 |
Test 3
Verdict: WRONG ANSWER
| input |
|---|
| 20 20 #################### #cccccccccccccccccc# #cccccccccccccccccc# #cccccccccccccccccc# ... |
| correct output |
|---|
| 35 |
| user output |
|---|
| 1000000000 |
Test 4
Verdict: WRONG ANSWER
| input |
|---|
| 400 400 DDD##D#DD##DDDDDDDD#DDDD###DDD... |
| correct output |
|---|
| 63 |
| user output |
|---|
| 6002 |
Test 5
Verdict: WRONG ANSWER
| input |
|---|
| 400 400 #DDD###D#DD#DD#DD##DDD##D#DDD#... |
| correct output |
|---|
| 11 |
| user output |
|---|
| 313 |
Test 6
Verdict: WRONG ANSWER
| input |
|---|
| 400 400 DDDDDDD#D#DDDD##D#DDDDDDD#DD##... |
| correct output |
|---|
| 37 |
| user output |
|---|
| 940 |
Test 7
Verdict: WRONG ANSWER
| input |
|---|
| 400 400 #######D#DDD#D##DD####DDDDDD##... |
| correct output |
|---|
| 55 |
| user output |
|---|
| 339 |
Test 8
Verdict: WRONG ANSWER
| input |
|---|
| 400 400 DD############################... |
| correct output |
|---|
| 184 |
| user output |
|---|
| 72550 |
Test 9
Verdict: WRONG ANSWER
| input |
|---|
| 20 20 DDDDD#DDDDDDDDD##D#D DccccD#DccccDcDD#c#D Dc###DD#c#ccDcccc#DD DccDc##DccccDcccc#DD ... |
| correct output |
|---|
| 4 |
| user output |
|---|
| 9 |
Test 10
Verdict: WRONG ANSWER
| input |
|---|
| 5 6 ####D# #DDDD# #D##c# #DDDc# ... |
| correct output |
|---|
| 1 |
| user output |
|---|
| 2 |
Test 11
Verdict: WRONG ANSWER
| input |
|---|
| 20 20 DDDDDD#DDDDDD#D#D#D# Dc#cccccccDcc#ccccDD DDcD#c##cDcc####Dc#D D#Dcccc#D##ccc#c#D#D ... |
| correct output |
|---|
| 5 |
| user output |
|---|
| 9 |
Test 12
Verdict: WRONG ANSWER
| input |
|---|
| 20 20 DDD#DDDD#DDDD#DDDD#D Dc##DDccDccD#DDcDDDD DcDDccc#cc#ccc##D##D DcccD#cDc##Dcccc##D# ... |
| correct output |
|---|
| 3 |
| user output |
|---|
| 4 |
Test 13
Verdict: WRONG ANSWER
| input |
|---|
| 20 20 #D###DD##DDDDDD###DD DDcDDccccDccDccDcc#D DcD##ccc#cDcDccccDD# DDcccc#Dc####c##ccDD ... |
| correct output |
|---|
| 7 |
| user output |
|---|
| 8 |
Test 14
Verdict: ACCEPTED
| input |
|---|
| 6 7 ####### #ccc#cD #c#c#c# #c#c#c# ... |
| correct output |
|---|
| 14 |
| user output |
|---|
| 14 |
Test 15
Verdict: ACCEPTED
| input |
|---|
| 5 5 DDDDD DDDDD DDcDD DDDDD ... |
| correct output |
|---|
| 1 |
| user output |
|---|
| 1 |
Test 16
Verdict: ACCEPTED
| input |
|---|
| 3 3 ### #cD ### 2 2 |
| correct output |
|---|
| 1 |
| user output |
|---|
| 1 |
