CSES - Datatähti 2025 loppu - Results
Submission details
Task:Suunnistus
Sender:Hattless
Submission time:2025-01-18 16:59:07 +0200
Language:C++ (C++20)
Status:READY
Result:0
Feedback
groupverdictscore
#10
#20
#30
Test results
testverdicttimegroup
#10.00 s3details
#2--1, 2, 3details
#3--1, 2, 3details
#40.01 s1, 2, 3details
#5ACCEPTED0.00 s1, 2, 3details
#60.00 s1, 2, 3details
#7--2, 3details
#8--2, 3details
#90.02 s2, 3details
#10--3details
#11--3details
#120.01 s3details
#13--3details
#140.01 s2, 3details
#15ACCEPTED0.00 s3details
#160.00 s3details
#17--2, 3details

Code

#include <bits/stdc++.h>
#define ln "\n";
using namespace std;
using ll = long long;
int n,m,k;
vector<string> vec;
vector<vector<ll>> dp;
vector<vector<bool>> seen;
void bfs(int currY, int currX, char tar) {
    queue<pair<int,pair<int,ll>>> q;
    q.push({currY,{currX,0}});
    while(!q.empty()) {
        int x = q.front().second.first;
        int y = q.front().first;
        ll d = q.front().second.second;
        q.pop();
        if(vec[y][x] == tar) {
            // cout << last << " " << depth << " " << curry << " " << currx << ln;
            if(dp[y][x] == -1) dp[y][x] = d;
            dp[y][x] = min(d,dp[y][x]); 
            break;
        }
        // if(y == 1 && x == 1) cout << "ran " <<  << ln;
        seen[y][x] = true;
        if(x+1 < m && vec[y][x+1] != '#' && seen[y][x+1]== false) q.push({y,{x+1,d+1}});
        if(x-1 >= 0 && vec[y][x-1] != '#' && seen[y][x-1]== false)q.push({y,{x-1,d+1}});
        if(y+1 < n && vec[y+1][x] != '#' && seen[y+1][x]== false) q.push({y+1,{x,d+1}});
        if(y-1 >= 0 && vec[y-1][x] != '#' && seen[y-1][x]== false) q.push({y-1,{x,d+1}});
    }
}


int main() {
    // ios::sync_with_stdio(0);
    // cin.tie(0);
    cin >> n >> m >> k;
    vec.resize(n);
    dp.assign(n,vector<ll> (m,-1));
    seen.assign(n,vector<bool> (m,false));
    for(int i =  0; i < n; i++) cin >> vec[i];
    for(int i = 0; i < n; i++) {
        for(int j = 0; j < m; j++) {
            if(vec[i][j] == 'S') {
                bfs(i,j,'E');
                break;
            }
        }
    }
    for(int i = 0; i < n; i++) {
        for(int j = 0; j < m ;j++) {
            if(vec[i][j] == 'E') cout << dp[i][j] << ln;
            break;
        }
    }
}

Test details

Test 1

Group: 3

Verdict:

input
10 10 9
S293#35616
#662963731
54975451#7
5162589168
...

correct output
25

user output
(empty)

Test 2

Group: 1, 2, 3

Verdict:

input
500 500 0
.................................

correct output
301

user output
(empty)

Test 3

Group: 1, 2, 3

Verdict:

input
500 500 0
.#.........#.#..##..#............

correct output
253

user output
(empty)

Test 4

Group: 1, 2, 3

Verdict:

input
500 500 0
...#......##.##.#.#..##..#..##...

correct output
-1

user output
(empty)

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:

input
1 500 0
.................................

correct output
166

user output
(empty)

Test 7

Group: 2, 3

Verdict:

input
500 500 9
.................................

correct output
3447

user output
(empty)

Test 8

Group: 2, 3

Verdict:

input
500 500 9
.#........#..................#...

correct output
4952

user output
(empty)

Test 9

Group: 2, 3

Verdict:

input
500 500 9
##.########.##########.#..#......

correct output
-1

user output
(empty)

Test 10

Group: 3

Verdict:

input
500 500 9
623475428948841896621266296765...

correct output
205

user output
(empty)

Test 11

Group: 3

Verdict:

input
500 500 9
7##814125813#3463#272134469457...

correct output
157

user output
(empty)

Test 12

Group: 3

Verdict:

input
500 500 9
##67##36##5#3###67###8972#61##...

correct output
-1

user output
(empty)

Test 13

Group: 3

Verdict:

input
500 500 9
....................#...#........

correct output
1313

user output
(empty)

Test 14

Group: 2, 3

Verdict:

input
499 499 9
S#...#...#...#...#...#...#...#...

correct output
1124942

user output
(empty)

Test 15

Group: 3

Verdict: ACCEPTED

input
500 1 9
1
6
1
3
...

correct output
332

user output
332

Test 16

Group: 3

Verdict:

input
1 500 9
996327784392827829434482995353...

correct output
135

user output
(empty)

Test 17

Group: 2, 3

Verdict:

input
500 500 9
.................................

correct output
-1

user output
(empty)