CSES - Datatähti 2025 loppu - Results
Submission details
Task:Suunnistus
Sender:Touko_Ursin
Submission time:2025-01-18 15:27:08 +0200
Language:C++ (C++20)
Status:READY
Result:0
Feedback
groupverdictscore
#10
#20
#30
Test results
testverdicttimegroup
#10.01 s3details
#20.94 s1, 2, 3details
#30.98 s1, 2, 3details
#4--1, 2, 3details
#5--1, 2, 3details
#6--1, 2, 3details
#70.94 s2, 3details
#80.96 s2, 3details
#9--2, 3details
#100.95 s3details
#110.97 s3details
#12--3details
#130.97 s3details
#14--2, 3details
#15--3details
#16--3details
#170.95 s2, 3details

Code

#include <bits/stdc++.h>

using namespace std;

int counts = 0;
int rasti = 1;
int n, m, k;
vector<int> tripdist;
vector<vector<int>> kartta;
pair<int,int> alku;
pair<int,int> loppu;
queue<pair<pair<int,int>, int>> cords;
bool found = false;

int main(){
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    
    cin>>n>>m>>k;



    kartta.resize(n);
    for(int i = 0; i<n; i++){
        kartta[i].resize(m, 0);
    }

    string x;

    for(int i = 0; i<n; i++){
        cin>>x;

        for(int j = 0; j<m; j++){
            if(x[j] == '#'){
                kartta[i][j] = -1;
            }
            else if(x[j] == '.') kartta[i][j] = 11;
            else if(x[j]=='S'){
                kartta[i][j] = 0;
                alku = {i,j};
            } 
            else if(x[j]=='E'){
                loppu = {i,j};
                kartta[i][j] = k+1;
            } 
            else{
                kartta[i][j] = x[j] - '0';
            }
            

        }
    }

    cords.push({{alku.first, alku.second}, 0});
    while(rasti != k+2){
        while(!found && !cords.empty()){
        int x = cords.front().first.first;
        int y = cords.front().first.second;
        int steps = cords.front().second;
        cords.pop();
        if(counts > 100) return 0;
        if((rasti == 10 && x == loppu.first && y == loppu.second)){
            tripdist.push_back(counts);
            cout<<"found"<<endl;
            return 0;
        }
        if(x != 0 && kartta[x-1][y] != -1){
            if(kartta[x-1][y] == rasti){
                rasti++;
                queue<pair<pair<int,int>, int>> chords;
                cords = chords;
                cords.push({{x, y}, steps+1});
                break;
                
            } 
            cords.push({{x-1, y},steps+1});
        }
        if(x != n-1&& kartta[x+1][y] != -1){
            if(kartta[x+1][y] == rasti){
                rasti++;
                queue<pair<pair<int,int>, int>> chords;
                cords = chords;
                cords.push({{x, y}, steps+1});
                break;
            } 
            cords.push({{x+1, y},steps+1});
        }
        if(y != 0&& kartta[x][y-1] != -1){
            if(kartta[x][y-1] == rasti){
                rasti++;
                queue<pair<pair<int,int>, int>> chords;
                cords = chords;
                cords.push({{x, y}, steps+1});
                break;
            }
            cords.push({{x, y-1}, steps+1});
        }
        if(y != m-1 && kartta[x][y+1] != -1){
            if(kartta[x][y+1] == rasti){
                rasti++;
                queue<pair<pair<int,int>, int>> chords;
                cords = chords;
                cords.push({{x, y}, steps+1});
                break;
            } 
            cords.push({{x, y+1}, steps+1});
        }   

    }

    }
    cout<<cords.front().second+k;

}

Test details

Test 1

Group: 3

Verdict:

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

correct output
25

user output
41

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:

input
500 1 0
.
.
.
.
...

correct output
77

user output
(empty)

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:

input
500 1 9
1
6
1
3
...

correct output
332

user output
(empty)

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)