| Task: | Hypyt |
| Sender: | Interaalimato |
| Submission time: | 2025-11-06 19:13:32 +0200 |
| Language: | C++ (C++11) |
| 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 | ACCEPTED | 0.00 s | 1, 2, 3, 4, 5 | details |
| #5 | ACCEPTED | 0.00 s | 1, 2, 3, 4, 5 | details |
| #6 | WRONG ANSWER | 0.01 s | 2, 5 | details |
| #7 | WRONG ANSWER | 0.01 s | 2, 5 | details |
| #8 | WRONG ANSWER | 0.01 s | 2, 5 | details |
| #9 | WRONG ANSWER | 0.12 s | 3, 4, 5 | details |
| #10 | WRONG ANSWER | 0.13 s | 3, 4, 5 | details |
| #11 | WRONG ANSWER | 0.14 s | 3, 4, 5 | details |
| #12 | WRONG ANSWER | 0.15 s | 4, 5 | details |
| #13 | WRONG ANSWER | 0.17 s | 4, 5 | details |
| #14 | WRONG ANSWER | 0.16 s | 4, 5 | details |
| #15 | WRONG ANSWER | 0.28 s | 5 | details |
| #16 | WRONG ANSWER | 0.36 s | 5 | details |
| #17 | WRONG ANSWER | 0.29 s | 5 | details |
| #18 | WRONG ANSWER | 0.41 s | 5 | details |
| #19 | WRONG ANSWER | 0.12 s | 5 | details |
| #20 | WRONG ANSWER | 0.13 s | 5 | details |
| #21 | WRONG ANSWER | 0.10 s | 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.08 s | 5 | details |
| #25 | ACCEPTED | 0.08 s | 5 | details |
| #26 | WRONG ANSWER | 0.18 s | 5 | details |
| #27 | ACCEPTED | 0.08 s | 5 | details |
Code
#include <bits/stdc++.h>
using namespace std;
// read from file instead of console:
// freopen("input.txt", "r", stdin);
// freopen("output.txt", "w", stdout);
typedef bitset<250> ibs;
const int M = 1000000007;
typedef long long ll;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<vector<int>> vvi;
typedef vector<vector<vector<int>>> vvvi;
typedef pair<int, int> pi;
typedef queue<int> qi;
typedef stack<int> si;
typedef priority_queue<int> pqi;
typedef deque<int> dqi;
typedef unordered_set<int> seti;
typedef unordered_map<int,int> mapi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
typedef vector<vector<vector<long long>>> vvvll;
typedef pair<long long, long long> pll;
typedef queue<long long> qll;
typedef stack<long long> sll;
typedef priority_queue<long long> pqll;
typedef deque<long long> dqll;
typedef unordered_set<long long> setll;
#define loop(i, a, b) for (int i = a; i < b; i++)
#define rloop(i, a, b) for (int i = a; i > b; i--)
#define each(a, c) for (auto a : c)
#define all(x) x.begin(), x.end()
#define PI M_PI
#define PB push_back
#define P push
#define POB pop_back
#define F first
#define S second
#define sz size()
#define R1(a) int a; cin >> a
#define R2(a, b) int a,b; cin >> a >> b
#define R3(a, b, c) int a,b,c; cin >> a >> b >> c
#define R4(a, b, c, d) int a,b,c,d; cin >> a >> b >> c >> d
#define WS(a) cout << a << " "
#define WN(a) cout << a << "\n"
#define WNL cout << "\n"
// graph of rows
vi g[251];
string mat[251];
int m,n,q;
ibs rows[251];
void construct_graph(){
loop(i,0,m){
ibs bs;
loop(j,0,n){
if(mat[i][j] == '.') bs.set(j);
}
rows[i] = bs;
}
loop(i,0,m){
loop(j,i+1,m){
auto common = rows[i] & rows[j];
if (!common.none()) {
g[i].PB(j);
g[j].PB(i);
}
}
}
}
// x = col, y = row
int query(int x1, int y1, int x2, int y2){
if(x1 == x2 && y1 == y2) return 0;
if(x1 == x2 || y1 == y2) return 1;
qi bfs;
qi temp;
int d[251];
d[y1] = 6767;
each(ri, g[y1]){
if(rows[ri][x1]) { d[ri] = 1; bfs.push(ri); }
else {d[ri] = 2; temp.push(ri);}
if(ri == y2) {
if(!rows[y1][x2]) d[ri]++;
return d[ri];
}
}
while(!temp.empty()){
bfs.push(temp.front());
temp.pop();
}
int resd = 67676;
while(!bfs.empty()){
int top = bfs.front();
bfs.pop();
if(resd <= d[top] + 1) return resd;
each(ri, g[top]){
if(d[ri] && ri != y2) continue;
d[ri] = d[top] + 2;
if(ri == y2) {
int tresd = d[ri];
if(!rows[top][x2]) tresd++;
resd = min(resd, tresd);
}
bfs.push(ri);
}
}
return -1;
}
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
cin >> m >> n >> q;
loop(i,0,m){
cin >> mat[i];
}
construct_graph();
loop(i,0,q){
R4(y1,x1,y2,x2);
cout << query(x1-1,y1-1,x2-1,y2-1) << "\n";
}
return 0;
}
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: 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: 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 2 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 |
|---|
| 2 3 3 3 3 ... |
Feedback: Incorrect character on line 30 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 |
|---|
| 2 2 1 2 1 ... |
Feedback: Incorrect character on line 3 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 2 ... |
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 3 ... |
Feedback: Incorrect character on line 85 col 1: expected "2", got "1"
Test 12
Group: 4, 5
Verdict: WRONG ANSWER
| input |
|---|
| 80 80 200000 *....**.***..****...*.....*...... |
| correct output |
|---|
| 2 2 2 2 2 ... |
| user output |
|---|
| 2 2 1 1 1 ... |
Feedback: Incorrect character on line 3 col 1: expected "2", got "1"
Test 13
Group: 4, 5
Verdict: WRONG ANSWER
| input |
|---|
| 80 80 200000 .***.*..*.***..*****....**...*... |
| correct output |
|---|
| 3 2 2 3 2 ... |
| user output |
|---|
| 3 2 2 3 2 ... |
Feedback: Incorrect character on line 8 col 1: expected "2", got "1"
Test 14
Group: 4, 5
Verdict: WRONG ANSWER
| input |
|---|
| 80 80 200000 *******.*****.*..*..****...***... |
| correct output |
|---|
| 2 3 1 2 2 ... |
| user output |
|---|
| 2 3 1 2 2 ... |
Feedback: Incorrect character on line 10 col 1: expected "2", got "1"
Test 15
Group: 5
Verdict: WRONG ANSWER
| input |
|---|
| 250 250 200000 *....*..*..*..**..*.........**... |
| correct output |
|---|
| 3 2 2 2 2 ... |
| user output |
|---|
| 3 2 1 2 2 ... |
Feedback: Incorrect character on line 3 col 1: expected "2", got "1"
Test 16
Group: 5
Verdict: WRONG ANSWER
| input |
|---|
| 250 250 200000 ..*....*..*......*.**.*.*..***... |
| correct output |
|---|
| 2 2 2 2 2 ... |
| user output |
|---|
| 2 1 1 2 2 ... |
Feedback: Incorrect character on line 2 col 1: expected "2", got "1"
Test 17
Group: 5
Verdict: WRONG ANSWER
| input |
|---|
| 250 250 200000 *..*.*****.*********.****.****... |
| correct output |
|---|
| 3 3 2 2 2 ... |
| user output |
|---|
| 3 3 1 2 2 ... |
Feedback: Incorrect character on line 3 col 1: expected "2", got "1"
Test 18
Group: 5
Verdict: WRONG ANSWER
| input |
|---|
| 250 250 200000 *********.**********.******.**... |
| correct output |
|---|
| 3 3 3 3 3 ... |
| user output |
|---|
| 3 3 3 3 3 ... |
Feedback: Incorrect character on line 35 col 1: expected "2", got "1"
Test 19
Group: 5
Verdict: WRONG ANSWER
| input |
|---|
| 250 250 200000 .*****************************... |
| correct output |
|---|
| 104 422 145 93 65 ... |
| user output |
|---|
| -1 -1 -1 -1 -1 ... |
Feedback: Incorrect character on line 1 col 1: expected "104", got "-1"
Test 20
Group: 5
Verdict: WRONG ANSWER
| input |
|---|
| 250 250 200000 ..****************************... |
| correct output |
|---|
| 57 155 38 65 98 ... |
| user output |
|---|
| -1 -1 -1 -1 -1 ... |
Feedback: Incorrect character on line 1 col 1: expected "57", got "-1"
Test 21
Group: 5
Verdict: WRONG ANSWER
| input |
|---|
| 250 250 200000 .*****************************... |
| correct output |
|---|
| 498 498 498 498 498 ... |
| user output |
|---|
| -1 -1 -1 -1 -1 ... |
Feedback: Incorrect character on line 1 col 1: expected "498", got "-1"
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: WRONG ANSWER
| input |
|---|
| 250 250 200000 ................................. |
| correct output |
|---|
| 2 2 2 2 2 ... |
| user output |
|---|
| 1 1 1 1 1 ... |
Feedback: Incorrect character on line 1 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 ... |
