Please sign in first.
Submission #65658841
Source Code Expand
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#include <atcoder/all>
using namespace atcoder;
int main(){
int H, W; cin >> H >> W;
vector<vector<char>> S(H, vector<char>(W)), ans(H, vector<char>(W, '-'));
queue<pair<int, int>> q;
for(int i = 0; i < H; i++){
for(int j = 0; j < W; j++){
cin >> S[i][j];
if(S[i][j] == 'E'){
ans[i][j] = 'E';
q.push({i, j});
}
if(S[i][j] == '#'){
ans[i][j] = '#';
}
}
}
vector<pair<int, int>> d = {{1, 0}, {0, 1}, {-1, 0}, {0, -1}};
while(!q.empty()){
auto [x, y] = q.front(); q.pop();
for(auto [dx, dy] : d){
int nx = x + dx, ny = y + dy;
if(0 <= nx && nx < H && 0 <= ny && ny < W && ans[nx][ny] == '-'){
if(dx == 1)ans[nx][ny] = '^';
if(dx == -1)ans[nx][ny] = 'v';
if(dy == 1)ans[nx][ny] = '<';
if(dy == -1)ans[nx][ny] = '>';
q.push({nx, ny});
}
}
}
for(int i = 0; i < H; i++){
for(int j = 0; j < W; j++){
cout << ans[i][j];
}
cout << endl;
}
}
Submission Info
| Submission Time | |
|---|---|
| Task | D - Escape Route |
| User | iphi7 |
| Language | C++ 23 (gcc 12.2) |
| Score | 400 |
| Code Size | 1290 Byte |
| Status | AC |
| Exec Time | 68 ms |
| Memory | 9488 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 | 3716 KiB |
| 00_sample_01.txt | AC | 1 ms | 3716 KiB |
| 00_sample_02.txt | AC | 1 ms | 3492 KiB |
| 01_random_00.txt | AC | 41 ms | 7656 KiB |
| 01_random_01.txt | AC | 34 ms | 6200 KiB |
| 01_random_02.txt | AC | 61 ms | 8744 KiB |
| 01_random_03.txt | AC | 59 ms | 6492 KiB |
| 01_random_04.txt | AC | 40 ms | 6896 KiB |
| 01_random_05.txt | AC | 46 ms | 6900 KiB |
| 01_random_06.txt | AC | 45 ms | 7636 KiB |
| 01_random_07.txt | AC | 64 ms | 7388 KiB |
| 01_random_08.txt | AC | 38 ms | 8160 KiB |
| 01_random_09.txt | AC | 36 ms | 5144 KiB |
| 01_random_10.txt | AC | 49 ms | 5960 KiB |
| 01_random_11.txt | AC | 68 ms | 9488 KiB |
| 01_random_12.txt | AC | 64 ms | 9336 KiB |
| 01_random_13.txt | AC | 57 ms | 6328 KiB |
| 01_random_14.txt | AC | 48 ms | 7336 KiB |
| 01_random_15.txt | AC | 62 ms | 7360 KiB |
| 02_corner_00.txt | AC | 53 ms | 5544 KiB |
| 02_corner_01.txt | AC | 46 ms | 5548 KiB |
| 02_corner_02.txt | AC | 57 ms | 9260 KiB |
| 02_corner_03.txt | AC | 1 ms | 3584 KiB |
| 02_corner_04.txt | AC | 2 ms | 3760 KiB |
| 02_corner_05.txt | AC | 56 ms | 5552 KiB |