| Task: | Suunnistus |
| Sender: | maweiyin24562 |
| Submission time: | 2025-01-18 13:58:08 +0200 |
| Language: | C++ (C++11) |
| Status: | READY |
| Result: | 31 |
| group | verdict | score |
|---|---|---|
| #1 | ACCEPTED | 31 |
| #2 | WRONG ANSWER | 0 |
| #3 | WRONG ANSWER | 0 |
| test | verdict | time | group | |
|---|---|---|---|---|
| #1 | WRONG ANSWER | 0.00 s | 3 | details |
| #2 | ACCEPTED | 0.02 s | 1, 2, 3 | details |
| #3 | ACCEPTED | 0.02 s | 1, 2, 3 | details |
| #4 | ACCEPTED | 0.02 s | 1, 2, 3 | details |
| #5 | ACCEPTED | 0.00 s | 1, 2, 3 | details |
| #6 | ACCEPTED | 0.00 s | 1, 2, 3 | details |
| #7 | WRONG ANSWER | 0.02 s | 2, 3 | details |
| #8 | WRONG ANSWER | 0.02 s | 2, 3 | details |
| #9 | WRONG ANSWER | 0.02 s | 2, 3 | details |
| #10 | WRONG ANSWER | 0.02 s | 3 | details |
| #11 | WRONG ANSWER | 0.02 s | 3 | details |
| #12 | WRONG ANSWER | 0.03 s | 3 | details |
| #13 | WRONG ANSWER | 0.03 s | 3 | details |
| #14 | WRONG ANSWER | 0.02 s | 2, 3 | details |
| #15 | WRONG ANSWER | 0.00 s | 3 | details |
| #16 | WRONG ANSWER | 0.00 s | 3 | details |
| #17 | WRONG ANSWER | 0.03 s | 2, 3 | details |
Code
#include <bits/stdc++.h>
#define ll long long
#define lbit(u) (u&(-u))
const int N=100009;
using namespace std;
char mp[509][509];
bool vst[509][509];
int n,m,sx,sy,ex,ey;
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
struct Node{
int x,y,d,nxt;
};
int cnt[10];
int k;
bool islegal(int x,int y){
return mp[x][y]!='#'&&!vst[x][y]&&x>=1&&x<=n&&y>=1&&y<=m;
}
queue<Node>q;
queue<Node>q_new;
void bfsnopatrol(){
q.push({sx,sy,0,0});
vst[sx][sy]=true;
while(!q.empty()){
Node now=q.front();
q.pop();
if(mp[now.x][now.y]=='E'){
cout<<now.d<<endl;
return;
}
for(int i=0;i<4;i++){
int nx=now.x+dx[i];
int ny=now.y+dy[i];
if(islegal(nx,ny)){
q.push({nx,ny,now.d+1,0});
vst[nx][ny]=true;
}
}
}
cout<<-1<<endl;
}
int main(){
cin>>n>>m>>k;
for(int i=1;i<=n;i++)
for(int j=1;j<=m;j++){
cin>>mp[i][j];
if(mp[i][j]=='S'){sx=i;sy=j;}
if(mp[i][j]=='E'){ex=i;ey=j;}
if(mp[i][j]>='0'&&mp[i][j]<='9'){
cnt[mp[i][j]-'0']++;
}
}
if(k==0)bfsnopatrol();
return 0;
}
/*
*/
Test details
Test 1
Group: 3
Verdict: WRONG ANSWER
| input |
|---|
| 10 10 9 S293#35616 #662963731 54975451#7 5162589168 ... |
| correct output |
|---|
| 25 |
| user output |
|---|
| (empty) |
Test 2
Group: 1, 2, 3
Verdict: ACCEPTED
| input |
|---|
| 500 500 0 ................................. |
| correct output |
|---|
| 301 |
| user output |
|---|
| 301 |
Test 3
Group: 1, 2, 3
Verdict: ACCEPTED
| input |
|---|
| 500 500 0 .#.........#.#..##..#............ |
| correct output |
|---|
| 253 |
| user output |
|---|
| 253 |
Test 4
Group: 1, 2, 3
Verdict: ACCEPTED
| input |
|---|
| 500 500 0 ...#......##.##.#.#..##..#..##... |
| correct output |
|---|
| -1 |
| user output |
|---|
| -1 |
Test 5
Group: 1, 2, 3
Verdict: ACCEPTED
| input |
|---|
| 500 1 0 . . . . ... |
| correct output |
|---|
| 77 |
| user output |
|---|
| 77 |
Test 6
Group: 1, 2, 3
Verdict: ACCEPTED
| input |
|---|
| 1 500 0 ................................. |
| correct output |
|---|
| 166 |
| user output |
|---|
| 166 |
Test 7
Group: 2, 3
Verdict: WRONG ANSWER
| input |
|---|
| 500 500 9 ................................. |
| correct output |
|---|
| 3447 |
| user output |
|---|
| (empty) |
Test 8
Group: 2, 3
Verdict: WRONG ANSWER
| input |
|---|
| 500 500 9 .#........#..................#... |
| correct output |
|---|
| 4952 |
| user output |
|---|
| (empty) |
Test 9
Group: 2, 3
Verdict: WRONG ANSWER
| input |
|---|
| 500 500 9 ##.########.##########.#..#...... |
| correct output |
|---|
| -1 |
| user output |
|---|
| (empty) |
Test 10
Group: 3
Verdict: WRONG ANSWER
| input |
|---|
| 500 500 9 623475428948841896621266296765... |
| correct output |
|---|
| 205 |
| user output |
|---|
| (empty) |
Test 11
Group: 3
Verdict: WRONG ANSWER
| input |
|---|
| 500 500 9 7##814125813#3463#272134469457... |
| correct output |
|---|
| 157 |
| user output |
|---|
| (empty) |
Test 12
Group: 3
Verdict: WRONG ANSWER
| input |
|---|
| 500 500 9 ##67##36##5#3###67###8972#61##... |
| correct output |
|---|
| -1 |
| user output |
|---|
| (empty) |
Test 13
Group: 3
Verdict: WRONG ANSWER
| input |
|---|
| 500 500 9 ....................#...#........ |
| correct output |
|---|
| 1313 |
| user output |
|---|
| (empty) |
Test 14
Group: 2, 3
Verdict: WRONG ANSWER
| input |
|---|
| 499 499 9 S#...#...#...#...#...#...#...#... |
| correct output |
|---|
| 1124942 |
| user output |
|---|
| (empty) |
Test 15
Group: 3
Verdict: WRONG ANSWER
| input |
|---|
| 500 1 9 1 6 1 3 ... |
| correct output |
|---|
| 332 |
| user output |
|---|
| (empty) |
Test 16
Group: 3
Verdict: WRONG ANSWER
| input |
|---|
| 1 500 9 996327784392827829434482995353... |
| correct output |
|---|
| 135 |
| user output |
|---|
| (empty) |
Test 17
Group: 2, 3
Verdict: WRONG ANSWER
| input |
|---|
| 500 500 9 ................................. |
| correct output |
|---|
| -1 |
| user output |
|---|
| (empty) |
