Submission details
Task:Hypyt
Sender:rendes
Submission time:2025-11-09 16:12:54 +0200
Language:C++ (C++20)
Status:READY
Result:100
Feedback
groupverdictscore
#1ACCEPTED10
#2ACCEPTED20
#3ACCEPTED15
#4ACCEPTED15
#5ACCEPTED40
Test results
testverdicttimegroup
#1ACCEPTED0.01 s1, 2, 3, 4, 5details
#2ACCEPTED0.01 s1, 2, 3, 4, 5details
#3ACCEPTED0.00 s1, 2, 3, 4, 5details
#4ACCEPTED0.01 s1, 2, 3, 4, 5details
#5ACCEPTED0.00 s1, 2, 3, 4, 5details
#6ACCEPTED0.33 s2, 5details
#7ACCEPTED0.23 s2, 5details
#8ACCEPTED0.13 s2, 5details
#9ACCEPTED0.08 s3, 4, 5details
#10ACCEPTED0.08 s3, 4, 5details
#11ACCEPTED0.08 s3, 4, 5details
#12ACCEPTED0.09 s4, 5details
#13ACCEPTED0.09 s4, 5details
#14ACCEPTED0.08 s4, 5details
#15ACCEPTED0.41 s5details
#16ACCEPTED0.31 s5details
#17ACCEPTED0.21 s5details
#18ACCEPTED0.15 s5details
#19ACCEPTED0.09 s5details
#20ACCEPTED0.10 s5details
#21ACCEPTED0.08 s5details
#22ACCEPTED0.00 s1, 2, 3, 4, 5details
#23ACCEPTED0.01 s1, 2, 3, 4, 5details
#24ACCEPTED0.09 s5details
#25ACCEPTED0.08 s5details
#26ACCEPTED0.51 s5details
#27ACCEPTED0.08 s5details

Compiler report

input/code.cpp: In function 'int main()':
input/code.cpp:43:14: warning: comparison of integer expressions of different signedness: 'uint' {aka 'unsigned int'} and 'int' [-Wsign-compare]
   43 |       if (tn < h) {
      |           ~~~^~~
input/code.cpp:45:44: warning: comparison of integer expressions of different signedness: 'uint' {aka 'unsigned int'} and 'int' [-Wsign-compare]
   45 |         for (uin fi = tr._Find_first(); fi < w; fi = tr._Find_next(fi)) {
      |                                         ~~~^~~
input/code.cpp:54:44: warning: comparison of integer expressions of different signedness: 'uint' {aka 'unsigned int'} and 'int' [-Wsign-compare]
   54 |         for (uin fi = tr._Find_first(); fi < h; fi = tr._Find_next(fi)) {
      |                                         ~~~^~~

Code

#include <algorithm>
#include <bits/stdc++.h>
using namespace std;

#define row bitset<250>
#define uin uint

static int h, w, qc;
static std::array<std::bitset<250>, 250> xopt, yopt;

int main() {
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(NULL);

  cin >> h >> w >> qc;

  string line;
  getline(cin, line);

  for (int y = 0; y < h && std::getline(cin, line); y++) {
    if (line.size() == 0)
      continue;
    for (int x = 0; x < w; x++) {
      if (line[x] == 46) {
        xopt[y][x] = 1;
        yopt[x][y] = 1;
      }
    }
  }

  array<array<uint, 500>, 500> dist;
  for (auto &r : dist)
    r.fill(500);

  for (int sn = 0; sn < w + h; sn++) {
    dist[sn][sn] = 0;
    queue<uin> nq;
    nq.push(sn);

    while (!nq.empty()) {
      uin tn = nq.front();
      nq.pop();
      if (tn < h) {
        auto &tr = xopt[tn];
        for (uin fi = tr._Find_first(); fi < w; fi = tr._Find_next(fi)) {
          uin nn = h + fi;
          if (dist[sn][nn] == 500) {
            dist[sn][nn] = dist[sn][tn] + 1;
            nq.push(nn);
          }
        }
      } else {
        auto &tr = yopt[tn - h];
        for (uin fi = tr._Find_first(); fi < h; fi = tr._Find_next(fi)) {
          if (dist[sn][fi] == 500) {
            dist[sn][fi] = dist[sn][tn] + 1;
            nq.push(fi);
          }
        }
      }
    }
  }

  int sx, sy, dx, dy;
  for (int i = 0; i < qc; i++) {
    cin >> sy >> sx >> dy >> dx;
    sx--;
    sy--;
    dx--;
    dy--;

    if (sx == dx || sy == dy) {
      if (sx == dx && sy == dy) {
        std::cout << 0 << "\n";
	continue;
      }
      std::cout << 1 << "\n";
      continue;
    }

    int cs = 500;
    if (int s = dist[sy][dy]; s < cs)
      cs = s;
    if (int s = dist[sy][dx+h]; s < cs)
      cs=s;
    if (int s = dist[sx+h][dx+h]; s < cs)
      cs=s;
    if (int s = dist[sx+h][dy]; s < cs)
      cs=s;
    if (cs == 500) {
      std::cout << -1 << "\n";
      continue;
    }
    std::cout << cs+1 << "\n";
  }
}

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: ACCEPTED

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

correct output
2
2
2
2
3
...

user output
2
2
2
2
3
...

Test 8

Group: 2, 5

Verdict: ACCEPTED

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

correct output
2
3
3
3
3
...

user output
2
3
3
3
3
...

Test 9

Group: 3, 4, 5

Verdict: ACCEPTED

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

correct output
2
2
2
2
2
...

user output
2
2
2
2
2
...

Test 10

Group: 3, 4, 5

Verdict: ACCEPTED

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

correct output
2
1
3
2
2
...

user output
2
1
3
2
2
...

Test 11

Group: 3, 4, 5

Verdict: ACCEPTED

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

correct output
3
3
3
3
3
...

user output
3
3
3
3
3
...

Test 12

Group: 4, 5

Verdict: ACCEPTED

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

correct output
2
2
2
2
2
...

user output
2
2
2
2
2
...

Test 13

Group: 4, 5

Verdict: ACCEPTED

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

correct output
3
2
2
3
2
...

user output
3
2
2
3
2
...

Test 14

Group: 4, 5

Verdict: ACCEPTED

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

correct output
2
3
1
2
2
...

user output
2
3
1
2
2
...

Test 15

Group: 5

Verdict: ACCEPTED

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

correct output
3
2
2
2
2
...

user output
3
2
2
2
2
...

Test 16

Group: 5

Verdict: ACCEPTED

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

correct output
2
2
2
2
2
...

user output
2
2
2
2
2
...

Test 17

Group: 5

Verdict: ACCEPTED

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

correct output
3
3
2
2
2
...

user output
3
3
2
2
2
...

Test 18

Group: 5

Verdict: ACCEPTED

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

correct output
3
3
3
3
3
...

user output
3
3
3
3
3
...

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: ACCEPTED

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

correct output
57
155
38
65
98
...

user output
57
155
38
65
98
...

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: ACCEPTED

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

correct output
2
2
2
2
2
...

user output
2
2
2
2
2
...

Test 27

Group: 5

Verdict: ACCEPTED

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

correct output
0
0
0
0
0
...

user output
0
0
0
0
0
...