12261 | 2024-12-10 17:56:12 | Ignác | Hegyi levegő | cpp17 | Wrong answer 0/100 | 3.118s | 293348 KiB |
#include<bits/stdc++.h>
using namespace std;
int main(){
int n, m, qn;
cin >> n >> m >> qn;
vector<vector<int>> h(n, vector<int>(m));
int mini=INT_MAX;
for(vector<int>& x : h){
for(int& y : x){
cin >> y;
mini=min(mini, y);
}
}
vector<vector<int>> res(n, vector<int>(m, INT_MAX));
priority_queue<array<int, 3>, vector<array<int, 3>>, greater<array<int, 3>>> pq;
for(int i=0;i<n;i++){
for(int j=0;j<m;j++){
if(h[i][j]==mini){ pq.push({h[i][j], i, j}); mini=INT_MIN;}
}
}
while(!pq.empty()){
auto [v, x, y]=pq.top();
pq.pop();
res[x][y]=v;
if(0<x && res[x-1][y]==INT_MAX) pq.push({max(v, h[x-1][y]), x-1, y});
if(x+1<n && res[x+1][y]==INT_MAX) pq.push({max(v, h[x+1][y]), x+1, y});
if(0<y && res[x][y-1]==INT_MAX) pq.push({max(v, h[x][y-1]), x, y-1});
if(y+1<m && res[x][y+1]==INT_MAX) pq.push({max(v, h[x][y+1]), x, y+1});
}
for(int i=0;i<qn;i++){
int a, b, c, d;
cin >> a >> b >> c >> d;
//cout << h[a-1][b-1] << ' ' << res[a-1][b-1] << ' ' << res[c-1][d-1] << '\n';
cout << max(h[a-1][b-1], max(res[a-1][b-1], res[c-1][d-1])) << '\n';
}
return 0;
}
Subtask | Sum | Test | Verdict | Time | Memory | ||
---|---|---|---|---|---|---|---|
subtask1 | 0/0 | ||||||
1 | Accepted | 1ms | 320 KiB | ||||
2 | Wrong answer | 1ms | 320 KiB | ||||
subtask2 | 0/19 | ||||||
3 | Wrong answer | 6ms | 320 KiB | ||||
4 | Time limit exceeded | 3.105s | 98840 KiB | ||||
5 | Wrong answer | 2.625s | 49768 KiB | ||||
6 | Wrong answer | 103ms | 3568 KiB | ||||
7 | Time limit exceeded | 3.118s | 293348 KiB | ||||
8 | Wrong answer | 1.049s | 25224 KiB | ||||
9 | Wrong answer | 74ms | 1964 KiB | ||||
10 | Wrong answer | 6ms | 1016 KiB | ||||
subtask3 | 0/20 | ||||||
11 | Accepted | 1ms | 320 KiB | ||||
12 | Wrong answer | 4ms | 508 KiB | ||||
13 | Wrong answer | 28ms | 568 KiB | ||||
14 | Wrong answer | 293ms | 2480 KiB | ||||
15 | Wrong answer | 771ms | 8260 KiB | ||||
subtask4 | 0/20 | ||||||
16 | Wrong answer | 670ms | 6992 KiB | ||||
17 | Wrong answer | 805ms | 59192 KiB | ||||
18 | Time limit exceeded | 3.085s | 201588 KiB | ||||
19 | Time limit exceeded | 3.088s | 201440 KiB | ||||
20 | Time limit exceeded | 3.101s | 201412 KiB | ||||
subtask5 | 0/31 | ||||||
21 | Wrong answer | 615ms | 17208 KiB | ||||
22 | Time limit exceeded | 3.091s | 99644 KiB | ||||
23 | Time limit exceeded | 3.105s | 271080 KiB | ||||
24 | Time limit exceeded | 3.101s | 198084 KiB | ||||
25 | Wrong answer | 531ms | 3508 KiB | ||||
26 | Time limit exceeded | 3.098s | 198336 KiB | ||||
27 | Time limit exceeded | 3.101s | 198236 KiB | ||||
28 | Wrong answer | 527ms | 3620 KiB | ||||
29 | Time limit exceeded | 3.098s | 2340 KiB | ||||
subtask6 | 0/10 | ||||||
30 | Wrong answer | 1.786s | 73500 KiB | ||||
31 | Time limit exceeded | 3.088s | 103016 KiB | ||||
32 | Time limit exceeded | 3.092s | 201416 KiB | ||||
33 | Time limit exceeded | 3.091s | 201432 KiB | ||||
34 | Wrong answer | 1.509s | 11160 KiB | ||||
35 | Time limit exceeded | 3.082s | 7096 KiB | ||||
36 | Time limit exceeded | 3.096s | 201404 KiB | ||||
37 | Time limit exceeded | 3.111s | 201408 KiB | ||||
38 | Wrong answer | 1.483s | 11672 KiB | ||||
39 | Time limit exceeded | 3.082s | 9060 KiB |