Submission details
Task:Hypyt
Sender:Verlet
Submission time:2025-11-03 13:06:38 +0200
Language:C++ (C++17)
Status:READY
Result:10
Feedback
groupverdictscore
#1ACCEPTED10
#20
#30
#40
#50
Test results
testverdicttimegroup
#1ACCEPTED0.00 s1, 2, 3, 4, 5details
#2ACCEPTED0.00 s1, 2, 3, 4, 5details
#3ACCEPTED0.00 s1, 2, 3, 4, 5details
#4ACCEPTED0.00 s1, 2, 3, 4, 5details
#5ACCEPTED0.00 s1, 2, 3, 4, 5details
#6ACCEPTED0.06 s2, 5details
#70.04 s2, 5details
#80.03 s2, 5details
#90.35 s3, 4, 5details
#100.35 s3, 4, 5details
#110.35 s3, 4, 5details
#120.35 s4, 5details
#130.35 s4, 5details
#140.36 s4, 5details
#150.41 s5details
#160.39 s5details
#170.38 s5details
#180.37 s5details
#19ACCEPTED0.37 s5details
#200.36 s5details
#21ACCEPTED0.35 s5details
#22ACCEPTED0.00 s1, 2, 3, 4, 5details
#23ACCEPTED0.00 s1, 2, 3, 4, 5details
#24ACCEPTED0.35 s5details
#25ACCEPTED0.35 s5details
#260.43 s5details
#27ACCEPTED0.35 s5details

Code

#include <algorithm>
#include <iostream>
#include <queue>

#define pb push_back
#define I first
#define D second

using namespace std;

int main()
{
  cin.sync_with_stdio(false);
  
  int h, w, k; cin >> h >> w >> k;

  string m[h];
  for (string & s : m)
    cin >> s;
  
  vector<int> adj[h + w];

  for (int r = 0; r < h; r++)
  for (int c = 0; c < w; c++)
  if (m[r][c] == '.')
  {
    adj[r].pb(h + c);
    adj[h + c].pb(r);
  }

  int dist[h + w][h + w];
  for (int s = 0; s < h + w; s++)
    for (int e = 0; e < h + w; e++)
      dist[s][e] = -2;
  
  int s[h + w], v[h + w];
  for (int i = 0; i < h + w; i++)
  {
    s[i] = h + w;
    v[i] = h + w;
  }
  
  pair<int, int> q[w + h];

  for (int i = 0; i < h + w; i++)
  {
    int qf = 0;
    int qt = 0;

    q[qt++] = {i, 0};

    while (qt > qf)
    {
      pair<int, int> n = q[qf++];

      if (v[n.I] == i)
        continue;
      
      v[n.I] = i;

      dist[i][n.I] = n.D;

      for (int & c : adj[n.I])
      {
        if (s[c] != i)
        {
          q[qt++] = {c, n.D + 1}; s[c] = i;
        }
      }
    }
  }

  while (k--)
  {
    int r1, c1, r2, c2;

    cin >> r1 >> c1 >> r2 >> c2;

    r1--; c1--; r2--; c2--;

    int d = 1 + min(min(dist[r1][r2], dist[r1][h + c2]), min(dist[h + c1][r2], dist[h + c1][h + c2]));

    if (r1 == r2 && c1 == c2)
      d = 0;

    cout << d << endl;
  }
}

Test details

Test 1 (public)

Group: 1, 2, 3, 4, 5

Verdict: ACCEPTED

input
4 6 5
.*.***
*...**
*****.
*..*.*
...

correct output
1
0
3
3
-1

user output
1
0
3
3
-1

Test 2

Group: 1, 2, 3, 4, 5

Verdict: ACCEPTED

input
10 10 10
..........
.....*....
........*.
*.*....*..
...

correct output
1
2
1
2
2
...

user output
1
2
1
2
2
...

Test 3

Group: 1, 2, 3, 4, 5

Verdict: ACCEPTED

input
10 10 10
*...***.**
*****.*...
**..**.**.
..**.**.*.
...

correct output
1
2
2
1
2
...

user output
1
2
2
1
2
...

Test 4

Group: 1, 2, 3, 4, 5

Verdict: ACCEPTED

input
10 10 10
***.*.****
**********
*.********
.*.***.**.
...

correct output
3
4
2
3
4
...

user output
3
4
2
3
4
...

Test 5

Group: 1, 2, 3, 4, 5

Verdict: ACCEPTED

input
10 10 1
.****.****
**.**..***
**********
*******..*
...

correct output
7

user output
7

Test 6

Group: 2, 5

Verdict: ACCEPTED

input
250 250 250
.*...*.....*******..**...*.......

correct output
2
3
3
2
2
...

user output
2
3
3
2
2
...

Test 7

Group: 2, 5

Verdict:

input
250 250 250
...*......**.**.*.*..**..*..**...

correct output
2
2
2
2
3
...

user output
2
2
2
2
3
...

Feedback: Incorrect character on line 228 col 1: expected "2", got "-1"

Test 8

Group: 2, 5

Verdict:

input
250 250 250
**..**..****.****.*.***.***..*...

correct output
2
3
3
3
3
...

user output
2
3
3
3
3
...

Feedback: Incorrect character on line 12 col 1: expected "3", got "-1"

Test 9

Group: 3, 4, 5

Verdict:

input
40 40 200000
...*.**.*..*.............*.*.....

correct output
2
2
2
2
2
...

user output
2
2
2
2
2
...

Feedback: Incorrect character on line 79 col 1: expected "3", got "-1"

Test 10

Group: 3, 4, 5

Verdict:

input
40 40 200000
**.**..*.*.*.******....****.*....

correct output
2
1
3
2
2
...

user output
2
1
3
2
2
...

Feedback: Incorrect character on line 13 col 1: expected "3", got "-1"

Test 11

Group: 3, 4, 5

Verdict:

input
40 40 200000
.*.*.**.*****.***.*.****.**.**...

correct output
3
3
3
3
3
...

user output
3
3
3
3
3
...

Feedback: Incorrect character on line 161 col 1: expected "3", got "-1"

Test 12

Group: 4, 5

Verdict:

input
80 80 200000
*....**.***..****...*.....*......

correct output
2
2
2
2
2
...

user output
2
2
2
2
2
...

Feedback: Incorrect character on line 21 col 1: expected "2", got "-1"

Test 13

Group: 4, 5

Verdict:

input
80 80 200000
.***.*..*.***..*****....**...*...

correct output
3
2
2
3
2
...

user output
3
2
2
3
2
...

Feedback: Incorrect character on line 11 col 1: expected "3", got "-1"

Test 14

Group: 4, 5

Verdict:

input
80 80 200000
*******.*****.*..*..****...***...

correct output
2
3
1
2
2
...

user output
2
3
1
2
2
...

Feedback: Incorrect character on line 51 col 1: expected "3", got "-1"

Test 15

Group: 5

Verdict:

input
250 250 200000
*....*..*..*..**..*.........**...

correct output
3
2
2
2
2
...

user output
3
2
2
2
2
...

Feedback: Incorrect character on line 39 col 1: expected "3", got "-1"

Test 16

Group: 5

Verdict:

input
250 250 200000
..*....*..*......*.**.*.*..***...

correct output
2
2
2
2
2
...

user output
2
2
2
2
2
...

Feedback: Incorrect character on line 106 col 1: expected "2", got "-1"

Test 17

Group: 5

Verdict:

input
250 250 200000
*..*.*****.*********.****.****...

correct output
3
3
2
2
2
...

user output
3
3
2
2
2
...

Feedback: Incorrect character on line 145 col 1: expected "3", got "-1"

Test 18

Group: 5

Verdict:

input
250 250 200000
*********.**********.******.**...

correct output
3
3
3
3
3
...

user output
3
3
3
3
3
...

Feedback: Incorrect character on line 1501 col 1: expected "3", got "-1"

Test 19

Group: 5

Verdict: ACCEPTED

input
250 250 200000
.*****************************...

correct output
104
422
145
93
65
...

user output
104
422
145
93
65
...

Test 20

Group: 5

Verdict:

input
250 250 200000
..****************************...

correct output
57
155
38
65
98
...

user output
57
155
38
65
98
...

Feedback: Incorrect character on line 20 col 1: expected "141", got "71"

Test 21

Group: 5

Verdict: ACCEPTED

input
250 250 200000
.*****************************...

correct output
498
498
498
498
498
...

user output
498
498
498
498
498
...

Test 22

Group: 1, 2, 3, 4, 5

Verdict: ACCEPTED

input
10 1 10
*
*
.
*
...

correct output
0
1
1
0
0
...

user output
0
1
1
0
0
...

Test 23

Group: 1, 2, 3, 4, 5

Verdict: ACCEPTED

input
1 10 10
........*.
1 7 1 10
1 4 1 7
1 5 1 1
...

correct output
1
1
1
1
1
...

user output
1
1
1
1
1
...

Test 24

Group: 5

Verdict: ACCEPTED

input
250 1 200000
*
.
*
.
...

correct output
1
1
1
1
1
...

user output
1
1
1
1
1
...

Test 25

Group: 5

Verdict: ACCEPTED

input
1 250 200000
*.*.*...*.*.**.***..**.*.*..**...

correct output
1
1
1
1
1
...

user output
1
1
1
1
1
...

Test 26

Group: 5

Verdict:

input
250 250 200000
.................................

correct output
2
2
2
2
2
...

user output
2
2
2
2
2
...

Feedback: Incorrect character on line 110 col 1: expected "2", got "-1"

Test 27

Group: 5

Verdict: ACCEPTED

input
250 250 200000
******************************...

correct output
0
0
0
0
0
...

user output
0
0
0
0
0
...