| Task: | Monikulmio |
| Sender: | sandyy |
| Submission time: | 2025-10-27 16:35:36 +0200 |
| Language: | C++ (C++17) |
| Status: | READY |
| Result: | 0 |
| group | verdict | score |
|---|---|---|
| #1 | RUNTIME ERROR | 0 |
| test | verdict | time | score | |
|---|---|---|---|---|
| #1 | RUNTIME ERROR | 0.00 s | 0 | details |
| #2 | RUNTIME ERROR | 0.00 s | 0 | details |
| #3 | RUNTIME ERROR | 0.00 s | 0 | details |
| #4 | RUNTIME ERROR | 0.00 s | 0 | details |
| #5 | RUNTIME ERROR | 0.00 s | 0 | details |
| #6 | RUNTIME ERROR | 0.00 s | 0 | details |
| #7 | RUNTIME ERROR | 0.00 s | 0 | details |
| #8 | RUNTIME ERROR | 0.00 s | 0 | details |
| #9 | RUNTIME ERROR | 0.00 s | 0 | details |
| #10 | RUNTIME ERROR | 0.00 s | 0 | details |
Compiler report
input/code.cpp: In function 'void setIO(std::string)':
input/code.cpp:9:24: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
9 | freopen((name+".in").c_str(), "r", stdin);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
input/code.cpp:10:24: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
10 | freopen((name+".out").c_str(), "w", stdout);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
input/code.cpp: In function 'int bfs(int, int, int, int)':
input/code.cpp:62:1: warning: control reaches end of non-void function [-Wreturn-type]
62 | }
| ^Code
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
void setIO(string name="") {
if(name.length()) {
freopen((name+".in").c_str(), "r", stdin);
freopen((name+".out").c_str(), "w", stdout);
}
}
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
template <class T>
using Tree = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define ll long long
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define debug(x) cout << (x) << "\n"
#define ar array
#define fi first
#define se second
const int mxN=251;
int n, m, q;
char grid[mxN][mxN];
vector<int> adj[mxN][2]; // 0 for rows, 1 for columns
bool vis[mxN][mxN], rowVis[mxN], colVis[mxN];
int bfs(int sx, int sy, int ex, int ey) {
queue<ar<int, 3>> q;
memset(vis, 0, sizeof(vis));
memset(rowVis, 0, sizeof(rowVis));
memset(colVis, 0, sizeof(colVis));
q.push({sx, sy, 0});
vis[sx][sy]=1;
while(q.size()) {
int x=q.front()[0], y=q.front()[1], d=q.front()[2];
q.pop();
if(x==ex && y==ey)
return d;
if(!rowVis[x]) {
for(int a:adj[x][0]) {
if(vis[x][a]) continue;
vis[x][a]=1;
q.push({x, a, d+1});
}
rowVis[x]=1;
}
if(!colVis[y]) {
for(int a:adj[y][1]) {
if(vis[a][y]) continue;
vis[a][y]=1;
q.push({a, y, d+1});
}
colVis[y]=1;
}
}
}
void solve() {
cin >> n >> m >> q;
for(int i=1; i<=n; i++) {
for(int j=1; j<=m; j++) {
cin >> grid[i][j];
if(grid[i][j]=='.') {
adj[i][0].pb(j);
}
}
}
for(int j=1; j<=m; j++) {
for(int i=1; i<=n; i++) {
if(grid[i][j]=='.') adj[j][1].pb(i);
}
}
for(int i=0; i<q; i++) {
int x1, y1, x2, y2;
cin >> x1 >> y1 >> x2 >> y2;
if((adj[x1][0].size()==1 && adj[y1][1].size()==1) || (adj[x2][0].size()==1 && adj[y2][1].size()==1)) {
cout << "-1\n";
} else {
cout << bfs(x1, y1, x2, y2) << "\n";
}
}
}
int main() {
cin.tie(0) -> sync_with_stdio(0);
//setIO("sleepy");
int T=1;
//cin >> T;
while(T--)
solve();
return 0;
}
Test details
Test 1 (public)
Verdict: RUNTIME ERROR
| input |
|---|
| 8 9 5 5 2 2 5 5 8 7 8 ... |
| correct output |
|---|
| ......... ....*.... .../#\... ../###\.. .*#####*. ... |
| user output |
|---|
| (empty) |
Test 2 (public)
Verdict: RUNTIME ERROR
| input |
|---|
| 20 40 4 5 10 5 30 15 30 15 10 |
| correct output |
|---|
| ................................. |
| user output |
|---|
| (empty) |
Test 3 (public)
Verdict: RUNTIME ERROR
| input |
|---|
| 20 40 29 8 7 13 2 14 2 9 7 ... |
| correct output |
|---|
| ................................. |
| user output |
|---|
| (empty) |
Test 4 (public)
Verdict: RUNTIME ERROR
| input |
|---|
| 20 40 14 5 12 5 25 8 28 13 28 ... |
| correct output |
|---|
| ................................. |
| user output |
|---|
| (empty) |
Test 5 (public)
Verdict: RUNTIME ERROR
| input |
|---|
| 20 40 12 3 20 7 16 7 9 11 13 ... |
| correct output |
|---|
| ................................. |
| user output |
|---|
| (empty) |
Test 6 (public)
Verdict: RUNTIME ERROR
| input |
|---|
| 9 35 33 2 3 2 8 4 8 4 5 ... |
| correct output |
|---|
| ................................. |
| user output |
|---|
| (empty) |
Test 7 (public)
Verdict: RUNTIME ERROR
| input |
|---|
| 30 100 69 6 10 6 14 7 14 7 18 ... |
| correct output |
|---|
| ................................. |
| user output |
|---|
| (empty) |
Test 8 (public)
Verdict: RUNTIME ERROR
| input |
|---|
| 40 60 192 11 3 11 5 10 6 11 7 ... |
| correct output |
|---|
| ................................. |
| user output |
|---|
| (empty) |
Test 9 (public)
Verdict: RUNTIME ERROR
| input |
|---|
| 50 100 142 1 1 1 7 1 11 1 14 ... |
| correct output |
|---|
| *=====*===*==*................... |
| user output |
|---|
| (empty) |
Test 10 (public)
Verdict: RUNTIME ERROR
| input |
|---|
| 100 100 1000 10 1 4 7 1 4 1 9 ... |
| correct output |
|---|
| ...*====*........................ |
| user output |
|---|
| (empty) |
