Task: | Suunnistus |
Sender: | Touko_Ursin |
Submission time: | 2025-01-18 15:26:46 +0200 |
Language: | C++ (C++20) |
Status: | READY |
Result: | 0 |
group | verdict | score |
---|---|---|
#1 | RUNTIME ERROR | 0 |
#2 | RUNTIME ERROR | 0 |
#3 | RUNTIME ERROR | 0 |
test | verdict | time | group | |
---|---|---|---|---|
#1 | RUNTIME ERROR | 0.00 s | 3 | details |
#2 | RUNTIME ERROR | 0.00 s | 1, 2, 3 | details |
#3 | RUNTIME ERROR | 0.00 s | 1, 2, 3 | details |
#4 | RUNTIME ERROR | 0.00 s | 1, 2, 3 | details |
#5 | RUNTIME ERROR | 0.00 s | 1, 2, 3 | details |
#6 | RUNTIME ERROR | 0.00 s | 1, 2, 3 | details |
#7 | RUNTIME ERROR | 0.00 s | 2, 3 | details |
#8 | RUNTIME ERROR | 0.00 s | 2, 3 | details |
#9 | RUNTIME ERROR | 0.00 s | 2, 3 | details |
#10 | RUNTIME ERROR | 0.00 s | 3 | details |
#11 | RUNTIME ERROR | 0.00 s | 3 | details |
#12 | RUNTIME ERROR | 0.00 s | 3 | details |
#13 | RUNTIME ERROR | 0.00 s | 3 | details |
#14 | RUNTIME ERROR | 0.00 s | 2, 3 | details |
#15 | RUNTIME ERROR | 0.00 s | 3 | details |
#16 | RUNTIME ERROR | 0.00 s | 3 | details |
#17 | RUNTIME ERROR | 0.00 s | 2, 3 | details |
Compiler report
input/code.cpp: In function 'int main()': input/code.cpp:16:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result] 16 | freopen("input.txt", "r", stdin); | ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~ input/code.cpp:17:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result] 17 | freopen("output.txt", "w", stdout); | ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
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: RUNTIME ERROR
input |
---|
10 10 9 S293#35616 #662963731 54975451#7 5162589168 ... |
correct output |
---|
25 |
user output |
---|
(empty) |
Test 2
Group: 1, 2, 3
Verdict: RUNTIME ERROR
input |
---|
500 500 0 ................................. |
correct output |
---|
301 |
user output |
---|
(empty) |
Test 3
Group: 1, 2, 3
Verdict: RUNTIME ERROR
input |
---|
500 500 0 .#.........#.#..##..#............ |
correct output |
---|
253 |
user output |
---|
(empty) |
Test 4
Group: 1, 2, 3
Verdict: RUNTIME ERROR
input |
---|
500 500 0 ...#......##.##.#.#..##..#..##... |
correct output |
---|
-1 |
user output |
---|
(empty) |
Test 5
Group: 1, 2, 3
Verdict: RUNTIME ERROR
input |
---|
500 1 0 . . . . ... |
correct output |
---|
77 |
user output |
---|
(empty) |
Test 6
Group: 1, 2, 3
Verdict: RUNTIME ERROR
input |
---|
1 500 0 ................................. |
correct output |
---|
166 |
user output |
---|
(empty) |
Test 7
Group: 2, 3
Verdict: RUNTIME ERROR
input |
---|
500 500 9 ................................. |
correct output |
---|
3447 |
user output |
---|
(empty) |
Test 8
Group: 2, 3
Verdict: RUNTIME ERROR
input |
---|
500 500 9 .#........#..................#... |
correct output |
---|
4952 |
user output |
---|
(empty) |
Test 9
Group: 2, 3
Verdict: RUNTIME ERROR
input |
---|
500 500 9 ##.########.##########.#..#...... |
correct output |
---|
-1 |
user output |
---|
(empty) |
Test 10
Group: 3
Verdict: RUNTIME ERROR
input |
---|
500 500 9 623475428948841896621266296765... |
correct output |
---|
205 |
user output |
---|
(empty) |
Test 11
Group: 3
Verdict: RUNTIME ERROR
input |
---|
500 500 9 7##814125813#3463#272134469457... |
correct output |
---|
157 |
user output |
---|
(empty) |
Test 12
Group: 3
Verdict: RUNTIME ERROR
input |
---|
500 500 9 ##67##36##5#3###67###8972#61##... |
correct output |
---|
-1 |
user output |
---|
(empty) |
Test 13
Group: 3
Verdict: RUNTIME ERROR
input |
---|
500 500 9 ....................#...#........ |
correct output |
---|
1313 |
user output |
---|
(empty) |
Test 14
Group: 2, 3
Verdict: RUNTIME ERROR
input |
---|
499 499 9 S#...#...#...#...#...#...#...#... |
correct output |
---|
1124942 |
user output |
---|
(empty) |
Test 15
Group: 3
Verdict: RUNTIME ERROR
input |
---|
500 1 9 1 6 1 3 ... |
correct output |
---|
332 |
user output |
---|
(empty) |
Test 16
Group: 3
Verdict: RUNTIME ERROR
input |
---|
1 500 9 996327784392827829434482995353... |
correct output |
---|
135 |
user output |
---|
(empty) |
Test 17
Group: 2, 3
Verdict: RUNTIME ERROR
input |
---|
500 500 9 ................................. |
correct output |
---|
-1 |
user output |
---|
(empty) |