| Task: | Suunnistus |
| Sender: | Kemm1706 |
| Submission time: | 2025-01-18 15:23:00 +0200 |
| Language: | C++ (C++11) |
| Status: | READY |
| Result: | 0 |
| group | verdict | score |
|---|---|---|
| #1 | WRONG ANSWER | 0 |
| #2 | WRONG ANSWER | 0 |
| #3 | WRONG ANSWER | 0 |
| test | verdict | time | group | |
|---|---|---|---|---|
| #1 | WRONG ANSWER | 0.00 s | 3 | details |
| #2 | WRONG ANSWER | 0.01 s | 1, 2, 3 | details |
| #3 | WRONG ANSWER | 0.01 s | 1, 2, 3 | details |
| #4 | ACCEPTED | 0.01 s | 1, 2, 3 | details |
| #5 | WRONG ANSWER | 0.00 s | 1, 2, 3 | details |
| #6 | WRONG ANSWER | 0.00 s | 1, 2, 3 | details |
| #7 | ACCEPTED | 0.04 s | 2, 3 | details |
| #8 | ACCEPTED | 0.08 s | 2, 3 | details |
| #9 | ACCEPTED | 0.01 s | 2, 3 | details |
| #10 | WRONG ANSWER | 0.01 s | 3 | details |
| #11 | WRONG ANSWER | 0.01 s | 3 | details |
| #12 | ACCEPTED | 0.01 s | 3 | details |
| #13 | WRONG ANSWER | 0.02 s | 3 | details |
| #14 | ACCEPTED | 0.04 s | 2, 3 | details |
| #15 | WRONG ANSWER | 0.00 s | 3 | details |
| #16 | WRONG ANSWER | 0.00 s | 3 | details |
| #17 | ACCEPTED | 0.01 s | 2, 3 | details |
Compiler report
input/code.cpp: In function 'int main()':
input/code.cpp:67:14: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
67 | auto [dis, no] = pq.front(); pq.pop();
| ^
input/code.cpp:68:14: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
68 | auto [x, y] = no;
| ^
input/code.cpp:41:23: warning: unused variable 'c' [-Wunused-variable]
41 | ll n, m, i, j, k, c = 1, ans = 0;
| ^Code
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector <ll> vl;
typedef vector <vl> vvl;
typedef pair <ll, ll> pl;
typedef vector <pl> vpl;
typedef stack <ll> stl;
typedef set <ll> sl;
typedef vector <char> vc;
typedef vector <vc> vvc;
typedef vector <bool> vb;
#define fi first
#define se second
#define pb push_back
pl d[4] = {{1, 0}, {-1, 0}, {0, 1}, {0, -1}};
ll cvt(ll x, ll y, ll m)
{
return x * m + y;
}
pl rct(ll k, ll m)
{
return {k / m, k % m};
}
bool valid(ll x, ll y, ll n, ll m, const vvc &g)
{
return (x < n && x >= 0 && y < m && y >= 0 && g[x][y] != '#');
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(0); cout.tie(0);
ll n, m, i, j, k, c = 1, ans = 0;
bool flag = false;
pl b;
string s;
cin >> n >> m >> k;
vvc g(n, vc(m));
vector <vb> vis(n, vb(m, false));
for(i = 0; i < n; i++)
{
cin >> s;
for(j = 0; j < m; j++)
{
g[i][j] = s[j];
if(s[j] == 'S')
{
b.fi = i; b.se = j;
vis[i][j] = true;
}
}
}
char target = '1';
queue <pair <ll, pl>> pq; pq.push({0, b});
while(!pq.empty())
{
auto [dis, no] = pq.front(); pq.pop();
auto [x, y] = no;
//cerr << x << " " << y << "\n";
for(i = 0; i < 4; i++)
{
ll xx = x + d[i].fi, yy = y + d[i].se;
if(valid(xx, yy, n, m, g) && !vis[xx][yy])
{
vis[xx][yy] = true;
if(g[xx][yy] == target)
{
ans += dis + 1;
while(!pq.empty())
pq.pop();
pq.push({0, {xx, yy}});
for(ll z = 0; z < n; z++)
{
fill(vis[z].begin(), vis[z].end(), false);
vis[xx][yy] = true;
}
if(target == 'E')
{
flag = true;
break;
}
target++;
if(target - '0' > k)
target = 'E';
break;
}
else
pq.push({dis + 1, {xx, yy}});
}
}
if(flag)
break;
}
if(flag)
cout << ans;
else
cout << -1;
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 |
|---|
| 31 |
Test 2
Group: 1, 2, 3
Verdict: WRONG ANSWER
| input |
|---|
| 500 500 0 ................................. |
| correct output |
|---|
| 301 |
| user output |
|---|
| -1 |
Test 3
Group: 1, 2, 3
Verdict: WRONG ANSWER
| input |
|---|
| 500 500 0 .#.........#.#..##..#............ |
| correct output |
|---|
| 253 |
| user output |
|---|
| -1 |
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: WRONG ANSWER
| input |
|---|
| 500 1 0 . . . . ... |
| correct output |
|---|
| 77 |
| user output |
|---|
| -1 |
Test 6
Group: 1, 2, 3
Verdict: WRONG ANSWER
| input |
|---|
| 1 500 0 ................................. |
| correct output |
|---|
| 166 |
| user output |
|---|
| -1 |
Test 7
Group: 2, 3
Verdict: ACCEPTED
| input |
|---|
| 500 500 9 ................................. |
| correct output |
|---|
| 3447 |
| user output |
|---|
| 3447 |
Test 8
Group: 2, 3
Verdict: ACCEPTED
| input |
|---|
| 500 500 9 .#........#..................#... |
| correct output |
|---|
| 4952 |
| user output |
|---|
| 4952 |
Test 9
Group: 2, 3
Verdict: ACCEPTED
| input |
|---|
| 500 500 9 ##.########.##########.#..#...... |
| correct output |
|---|
| -1 |
| user output |
|---|
| -1 |
Test 10
Group: 3
Verdict: WRONG ANSWER
| input |
|---|
| 500 500 9 623475428948841896621266296765... |
| correct output |
|---|
| 205 |
| user output |
|---|
| 217 |
Test 11
Group: 3
Verdict: WRONG ANSWER
| input |
|---|
| 500 500 9 7##814125813#3463#272134469457... |
| correct output |
|---|
| 157 |
| user output |
|---|
| 179 |
Test 12
Group: 3
Verdict: ACCEPTED
| input |
|---|
| 500 500 9 ##67##36##5#3###67###8972#61##... |
| correct output |
|---|
| -1 |
| user output |
|---|
| -1 |
Test 13
Group: 3
Verdict: WRONG ANSWER
| input |
|---|
| 500 500 9 ....................#...#........ |
| correct output |
|---|
| 1313 |
| user output |
|---|
| 1571 |
Test 14
Group: 2, 3
Verdict: ACCEPTED
| input |
|---|
| 499 499 9 S#...#...#...#...#...#...#...#... |
| correct output |
|---|
| 1124942 |
| user output |
|---|
| 1124942 |
Test 15
Group: 3
Verdict: WRONG ANSWER
| input |
|---|
| 500 1 9 1 6 1 3 ... |
| correct output |
|---|
| 332 |
| user output |
|---|
| 364 |
Test 16
Group: 3
Verdict: WRONG ANSWER
| input |
|---|
| 1 500 9 996327784392827829434482995353... |
| correct output |
|---|
| 135 |
| user output |
|---|
| 169 |
Test 17
Group: 2, 3
Verdict: ACCEPTED
| input |
|---|
| 500 500 9 ................................. |
| correct output |
|---|
| -1 |
| user output |
|---|
| -1 |
