| Task: | Hypyt |
| Sender: | OorigamiK |
| Submission time: | 2025-10-31 20:45:12 +0200 |
| Language: | C++ (C++20) |
| Status: | READY |
| Result: | 0 |
| group | verdict | score |
|---|---|---|
| #1 | WRONG ANSWER | 0 |
| #2 | WRONG ANSWER | 0 |
| #3 | WRONG ANSWER | 0 |
| #4 | WRONG ANSWER | 0 |
| #5 | WRONG ANSWER | 0 |
| test | verdict | time | group | |
|---|---|---|---|---|
| #1 | ACCEPTED | 0.00 s | 1, 2, 3, 4, 5 | details |
| #2 | WRONG ANSWER | 0.00 s | 1, 2, 3, 4, 5 | details |
| #3 | WRONG ANSWER | 0.00 s | 1, 2, 3, 4, 5 | details |
| #4 | WRONG ANSWER | 0.00 s | 1, 2, 3, 4, 5 | details |
| #5 | ACCEPTED | 0.00 s | 1, 2, 3, 4, 5 | details |
| #6 | WRONG ANSWER | 0.05 s | 2, 5 | details |
| #7 | WRONG ANSWER | 0.03 s | 2, 5 | details |
| #8 | WRONG ANSWER | 0.02 s | 2, 5 | details |
| #9 | WRONG ANSWER | 0.83 s | 3, 4, 5 | details |
| #10 | WRONG ANSWER | 0.68 s | 3, 4, 5 | details |
| #11 | WRONG ANSWER | 0.54 s | 3, 4, 5 | details |
| #12 | TIME LIMIT EXCEEDED | -- | 4, 5 | details |
| #13 | TIME LIMIT EXCEEDED | -- | 4, 5 | details |
| #14 | TIME LIMIT EXCEEDED | -- | 4, 5 | details |
| #15 | TIME LIMIT EXCEEDED | -- | 5 | details |
| #16 | TIME LIMIT EXCEEDED | -- | 5 | details |
| #17 | TIME LIMIT EXCEEDED | -- | 5 | details |
| #18 | TIME LIMIT EXCEEDED | -- | 5 | details |
| #19 | TIME LIMIT EXCEEDED | -- | 5 | details |
| #20 | TIME LIMIT EXCEEDED | -- | 5 | details |
| #21 | TIME LIMIT EXCEEDED | -- | 5 | details |
| #22 | ACCEPTED | 0.00 s | 1, 2, 3, 4, 5 | details |
| #23 | ACCEPTED | 0.00 s | 1, 2, 3, 4, 5 | details |
| #24 | ACCEPTED | 0.19 s | 5 | details |
| #25 | ACCEPTED | 0.19 s | 5 | details |
| #26 | TIME LIMIT EXCEEDED | -- | 5 | details |
| #27 | ACCEPTED | 0.21 s | 5 | details |
Code
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <unordered_map>
using namespace std;
struct Row{
int parity;
int index;
};
int minDist(vector<vector<bool>>& grid, vector<vector<bool>>& rowAcces, int n, int x1, int y1, int x2, int y2){
if (!grid[y2][x2]){
return -1;
}
if (x1==x2 && y1==y2){
return 0;
}
if (x1==x2 || y1==y2){
return 1;
}
stack<Row> curRows={};
stack<Row> nextRows;
vector<bool> doneRows(n, true);
for (int y=0;y<n;y++){
if (grid[y][x1] && y!=y1){
doneRows[y]=false;
nextRows.push({1, y});
//cout<<"row "<<y<<" parity"<<1<<"\n";
}
}
nextRows.push({0,y1});
doneRows[y1]=false;
int k=1;
while (!nextRows.empty()){
//cout<<"k "<<k<<"\n";
curRows=nextRows;
nextRows={};
while (!curRows.empty()){
Row curRow = curRows.top();
for (int row=0;row<n;row++){
if (rowAcces[curRow.index][row]){
if (doneRows[row]){
doneRows[row]=false;
//cout<<"row "<<row<<" parity"<<curRow.parity<<"\n";
if (row==y2){
if (grid[curRow.index][x2]){
return 2*k+curRow.parity;
}
else{
return 2*k+curRow.parity+1;
}
}
nextRows.push({curRow.parity, row});
}
}
}
curRows.pop();
}
k++;
}
return -1;
}
int main(){
int n,m,q;
cin>>n>>m>>q;
vector<vector<bool>> grid(n, vector<bool>(m,0));
vector<vector<bool>> rowAcces(n, vector<bool>(n, false));
for (int i=0;i<n;i++){
string s;
cin>>s;
for (int j=0;j<m;j++){
grid[i][j]=(s[j]=='.');
}
}
for (int i=0;i<m;i++){
vector<int> rows;
for (int j=0;j<n;j++){
if (grid[j][i]){
rows.push_back(j);
}
}
for (int row : rows){
for (int row1 : rows){
rowAcces[row][row1]=true;
}
}
}
//int x1,x2,y1,y2;
//cin>>y1>>x1>>y2>>x2;
//cout<<minDist(grid, rowAcces, n, x1-1, y1-1, x2-1, y2-1)<<"\n";
vector<int> input(4*q, 0);
for (int i=0;i<q;i++){
int x1,x2,y1,y2;
cin>>y1>>x1>>y2>>x2;
input[4*i+0]=x1;
input[4*i+1]=y1;
input[4*i+2]=x2;
input[4*i+3]=y2;
}
for (int i=0;i<q;i++){
int x1=input[4*i+0];
int y1=input[4*i+1];
int x2=input[4*i+2];
int y2=input[4*i+3];
cout<<minDist(grid, rowAcces, n, x1-1, y1-1, x2-1, y2-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: WRONG ANSWER
| input |
|---|
| 10 10 10 .......... .....*.... ........*. *.*....*.. ... |
| correct output |
|---|
| 1 2 1 2 2 ... |
| user output |
|---|
| 1 -1 1 2 2 ... |
Feedback: Incorrect character on line 2 col 1: expected "2", got "-1"
Test 3
Group: 1, 2, 3, 4, 5
Verdict: WRONG ANSWER
| input |
|---|
| 10 10 10 *...***.** *****.*... **..**.**. ..**.**.*. ... |
| correct output |
|---|
| 1 2 2 1 2 ... |
| user output |
|---|
| 1 2 2 1 -1 ... |
Feedback: Incorrect character on line 5 col 1: expected "2", got "-1"
Test 4
Group: 1, 2, 3, 4, 5
Verdict: WRONG ANSWER
| input |
|---|
| 10 10 10 ***.*.**** ********** *.******** .*.***.**. ... |
| correct output |
|---|
| 3 4 2 3 4 ... |
| user output |
|---|
| 3 4 -1 3 4 ... |
Feedback: Incorrect character on line 3 col 1: expected "2", got "-1"
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: WRONG ANSWER
| input |
|---|
| 250 250 250 .*...*.....*******..**...*....... |
| correct output |
|---|
| 2 3 3 2 2 ... |
| user output |
|---|
| -1 3 3 2 2 ... |
Feedback: Incorrect character on line 1 col 1: expected "2", got "-1"
Test 7
Group: 2, 5
Verdict: WRONG ANSWER
| input |
|---|
| 250 250 250 ...*......**.**.*.*..**..*..**... |
| correct output |
|---|
| 2 2 2 2 3 ... |
| user output |
|---|
| 2 2 -1 -1 3 ... |
Feedback: Incorrect character on line 3 col 1: expected "2", got "-1"
Test 8
Group: 2, 5
Verdict: WRONG ANSWER
| input |
|---|
| 250 250 250 **..**..****.****.*.***.***..*... |
| correct output |
|---|
| 2 3 3 3 3 ... |
| user output |
|---|
| -1 3 3 3 3 ... |
Feedback: Incorrect character on line 1 col 1: expected "2", got "-1"
Test 9
Group: 3, 4, 5
Verdict: WRONG ANSWER
| input |
|---|
| 40 40 200000 ...*.**.*..*.............*.*..... |
| correct output |
|---|
| 2 2 2 2 2 ... |
| user output |
|---|
| -1 2 -1 2 -1 ... |
Feedback: Incorrect character on line 1 col 1: expected "2", got "-1"
Test 10
Group: 3, 4, 5
Verdict: WRONG ANSWER
| input |
|---|
| 40 40 200000 **.**..*.*.*.******....****.*.... |
| correct output |
|---|
| 2 1 3 2 2 ... |
| user output |
|---|
| -1 1 3 -1 -1 ... |
Feedback: Incorrect character on line 1 col 1: expected "2", got "-1"
Test 11
Group: 3, 4, 5
Verdict: WRONG ANSWER
| input |
|---|
| 40 40 200000 .*.*.**.*****.***.*.****.**.**... |
| correct output |
|---|
| 3 3 3 3 3 ... |
| user output |
|---|
| 3 3 3 3 4 ... |
Feedback: Incorrect character on line 5 col 1: expected "3", got "4"
Test 12
Group: 4, 5
Verdict: TIME LIMIT EXCEEDED
| input |
|---|
| 80 80 200000 *....**.***..****...*.....*...... |
| correct output |
|---|
| 2 2 2 2 2 ... |
| user output |
|---|
| (empty) |
Test 13
Group: 4, 5
Verdict: TIME LIMIT EXCEEDED
| input |
|---|
| 80 80 200000 .***.*..*.***..*****....**...*... |
| correct output |
|---|
| 3 2 2 3 2 ... |
| user output |
|---|
| (empty) |
Test 14
Group: 4, 5
Verdict: TIME LIMIT EXCEEDED
| input |
|---|
| 80 80 200000 *******.*****.*..*..****...***... |
| correct output |
|---|
| 2 3 1 2 2 ... |
| user output |
|---|
| (empty) |
Test 15
Group: 5
Verdict: TIME LIMIT EXCEEDED
| input |
|---|
| 250 250 200000 *....*..*..*..**..*.........**... |
| correct output |
|---|
| 3 2 2 2 2 ... |
| user output |
|---|
| (empty) |
Test 16
Group: 5
Verdict: TIME LIMIT EXCEEDED
| input |
|---|
| 250 250 200000 ..*....*..*......*.**.*.*..***... |
| correct output |
|---|
| 2 2 2 2 2 ... |
| user output |
|---|
| (empty) |
Test 17
Group: 5
Verdict: TIME LIMIT EXCEEDED
| input |
|---|
| 250 250 200000 *..*.*****.*********.****.****... |
| correct output |
|---|
| 3 3 2 2 2 ... |
| user output |
|---|
| (empty) |
Test 18
Group: 5
Verdict: TIME LIMIT EXCEEDED
| input |
|---|
| 250 250 200000 *********.**********.******.**... |
| correct output |
|---|
| 3 3 3 3 3 ... |
| user output |
|---|
| (empty) |
Test 19
Group: 5
Verdict: TIME LIMIT EXCEEDED
| input |
|---|
| 250 250 200000 .*****************************... |
| correct output |
|---|
| 104 422 145 93 65 ... |
| user output |
|---|
| (empty) |
Test 20
Group: 5
Verdict: TIME LIMIT EXCEEDED
| input |
|---|
| 250 250 200000 ..****************************... |
| correct output |
|---|
| 57 155 38 65 98 ... |
| user output |
|---|
| (empty) |
Test 21
Group: 5
Verdict: TIME LIMIT EXCEEDED
| input |
|---|
| 250 250 200000 .*****************************... |
| correct output |
|---|
| 498 498 498 498 498 ... |
| user output |
|---|
| (empty) |
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: TIME LIMIT EXCEEDED
| input |
|---|
| 250 250 200000 ................................. |
| correct output |
|---|
| 2 2 2 2 2 ... |
| user output |
|---|
| (empty) |
Test 27
Group: 5
Verdict: ACCEPTED
| input |
|---|
| 250 250 200000 ******************************... |
| correct output |
|---|
| 0 0 0 0 0 ... |
| user output |
|---|
| 0 0 0 0 0 ... |
