Submission #7054538
Source Code Expand
//#include <bits/stdc++.h> #include <iostream> #include <string> #include <vector> #include <queue> using namespace std; struct hoge{ int x; int y; int depth; }; int H,W,x1,y1,x2,y2; int x,y,depth; char maze[55][55]; queue<hoge> q; int xrl[4] = {0,0,1,-1}; int yrl[4] = {1,-1,0,0}; int bfs(){ while(!q.empty()){ hoge now = q.front(); q.pop(); x = now.x; y = now.y; depth = now.depth; //cout << x << y << depth << endl; if (x == x2 && y == y2) return depth; for (int i = 0; i < 4; i++){ hoge next = {x + xrl[i],y + yrl[i],depth + 1}; if (0 <= next.x && next.x <= H-1 && 0 <= next.y && next.y <= W-1 && maze[next.x][next.y] == '.'){ maze[next.x][next.y] = '#'; q.push(next); } } } return 0; } int main(){ cin >> H >> W >> x1 >> y1 >> x2 >> y2; cout << H << W << endl; x1--,y1--,x2--,y2--; for (int i = 0; i < H; i++){ for (int j = 0; j < W; j++){ cin >> maze[i][j]; } } hoge start = {x1,y1,0}; q.push(start); cout << bfs() << '\n'; }
Submission Info
Submission Time | |
---|---|
Task | A - 幅優先探索 |
User | karudano |
Language | C++14 (GCC 5.4.1) |
Score | 0 |
Code Size | 1228 Byte |
Status | WA |
Exec Time | 1 ms |
Memory | 256 KB |
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 0 / 100 | ||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | subtask0_sample01.txt, subtask0_sample02.txt, subtask0_sample03.txt |
All | subtask0_sample01.txt, subtask0_sample02.txt, subtask0_sample03.txt, subtask1_01.txt, subtask1_02.txt, subtask1_03.txt, subtask1_04.txt, subtask1_05.txt, subtask1_06.txt, subtask1_07.txt, subtask1_08.txt, subtask1_09.txt, subtask1_10.txt, subtask1_11.txt, subtask1_12.txt, subtask1_13.txt, subtask1_14.txt, subtask1_15.txt, subtask1_16.txt, subtask1_17.txt, subtask1_18.txt, subtask1_19.txt, subtask1_20.txt, subtask1_21.txt, subtask1_22.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
subtask0_sample01.txt | WA | 1 ms | 256 KB |
subtask0_sample02.txt | WA | 1 ms | 256 KB |
subtask0_sample03.txt | WA | 1 ms | 256 KB |
subtask1_01.txt | WA | 1 ms | 256 KB |
subtask1_02.txt | WA | 1 ms | 256 KB |
subtask1_03.txt | WA | 1 ms | 256 KB |
subtask1_04.txt | WA | 1 ms | 256 KB |
subtask1_05.txt | WA | 1 ms | 256 KB |
subtask1_06.txt | WA | 1 ms | 256 KB |
subtask1_07.txt | WA | 1 ms | 256 KB |
subtask1_08.txt | WA | 1 ms | 256 KB |
subtask1_09.txt | WA | 1 ms | 256 KB |
subtask1_10.txt | WA | 1 ms | 256 KB |
subtask1_11.txt | WA | 1 ms | 256 KB |
subtask1_12.txt | WA | 1 ms | 256 KB |
subtask1_13.txt | WA | 1 ms | 256 KB |
subtask1_14.txt | WA | 1 ms | 256 KB |
subtask1_15.txt | WA | 1 ms | 256 KB |
subtask1_16.txt | WA | 1 ms | 256 KB |
subtask1_17.txt | WA | 1 ms | 256 KB |
subtask1_18.txt | WA | 1 ms | 256 KB |
subtask1_19.txt | WA | 1 ms | 256 KB |
subtask1_20.txt | WA | 1 ms | 256 KB |
subtask1_21.txt | WA | 1 ms | 256 KB |
subtask1_22.txt | WA | 1 ms | 256 KB |