Submission #65656868
Source Code Expand
#include <iostream>
#include <queue>
using namespace std;
int dx[4] = {0, 0, 1, -1};
int dy[4] = {1, -1, 0, 0};
char ch[4] = {'<','>','^','v'};
int n, m, d[1005][1005];
char dt[1005][1005];
queue <int> qx, qy;
int main()
{
cin >> n >> m;
for(int i = 1; i <= n; i++) {
for(int j = 1; j <= m; j++) {
cin >> dt[i][j];
if (dt[i][j] == 'E') {
d[i][j] = 1;
qx.push(i);
qy.push(j);
}
}
}
while (!qx.empty()) {
int x = qx.front(), y = qy.front();
qx.pop(), qy.pop();
for(int i = 0; i < 4; i++) {
int tx = x + dx[i];
int ty = y + dy[i];
if (tx > 0 && tx <= n && ty > 0 && ty <= m)
if (d[tx][ty] == 0 && dt[tx][ty] != '#') {
d[tx][ty] = 1;
qx.push(tx), qy.push(ty);
dt[tx][ty] = ch[i];
}
}
}
for(int i = 1; i <= n; i++) {
for(int j = 1; j <= m; j++) {
cout << dt[i][j];
}
cout << endl;
}
return 0;
}
Submission Info
| Submission Time | |
|---|---|
| Task | D - Escape Route |
| User | gobywind |
| Language | C++ 20 (gcc 12.2) |
| Score | 400 |
| Code Size | 918 Byte |
| Status | AC |
| Exec Time | 68 ms |
| Memory | 12352 KiB |
Judge Result
| Set Name | Sample | All | ||||
|---|---|---|---|---|---|---|
| Score / Max Score | 0 / 0 | 400 / 400 | ||||
| Status |
|
|
| Set Name | Test Cases |
|---|---|
| Sample | 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt |
| All | 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 01_random_00.txt, 01_random_01.txt, 01_random_02.txt, 01_random_03.txt, 01_random_04.txt, 01_random_05.txt, 01_random_06.txt, 01_random_07.txt, 01_random_08.txt, 01_random_09.txt, 01_random_10.txt, 01_random_11.txt, 01_random_12.txt, 01_random_13.txt, 01_random_14.txt, 01_random_15.txt, 02_corner_00.txt, 02_corner_01.txt, 02_corner_02.txt, 02_corner_03.txt, 02_corner_04.txt, 02_corner_05.txt |
| Case Name | Status | Exec Time | Memory |
|---|---|---|---|
| 00_sample_00.txt | AC | 1 ms | 3668 KiB |
| 00_sample_01.txt | AC | 1 ms | 3500 KiB |
| 00_sample_02.txt | AC | 1 ms | 3480 KiB |
| 01_random_00.txt | AC | 42 ms | 9320 KiB |
| 01_random_01.txt | AC | 37 ms | 9800 KiB |
| 01_random_02.txt | AC | 62 ms | 11232 KiB |
| 01_random_03.txt | AC | 62 ms | 9276 KiB |
| 01_random_04.txt | AC | 40 ms | 9084 KiB |
| 01_random_05.txt | AC | 48 ms | 10204 KiB |
| 01_random_06.txt | AC | 45 ms | 9196 KiB |
| 01_random_07.txt | AC | 66 ms | 10204 KiB |
| 01_random_08.txt | AC | 38 ms | 11456 KiB |
| 01_random_09.txt | AC | 40 ms | 8484 KiB |
| 01_random_10.txt | AC | 52 ms | 8268 KiB |
| 01_random_11.txt | AC | 68 ms | 12024 KiB |
| 01_random_12.txt | AC | 65 ms | 12352 KiB |
| 01_random_13.txt | AC | 61 ms | 8988 KiB |
| 01_random_14.txt | AC | 49 ms | 9184 KiB |
| 01_random_15.txt | AC | 65 ms | 10000 KiB |
| 02_corner_00.txt | AC | 50 ms | 8356 KiB |
| 02_corner_01.txt | AC | 43 ms | 4500 KiB |
| 02_corner_02.txt | AC | 66 ms | 12048 KiB |
| 02_corner_03.txt | AC | 1 ms | 3484 KiB |
| 02_corner_04.txt | AC | 5 ms | 8376 KiB |
| 02_corner_05.txt | AC | 58 ms | 8376 KiB |