#include <bits/stdc++.h>
using namespace std;
int Measure(int RM,int CM);
void Pinpoint(int RP,int CP);
/*
vector<vector<int>> high; vector<pair<int,int>> ans;
int Measure(int RM,int CM){ return high[RM-1][CM-1]; }
void Pinpoint(int RP,int CP){ ans.emplace_back(RP,CP); }
void Rescue(int R,int C,int MR,int MC,int X);
int main(){
int q; cin >> q; while(q--){
int R,C,MR,MC,X; cin >> R >> C >> MR >> MC >> X;
high.resize(R);
for (auto& a:high){
a.resize(C); for (int& b:a) cin >> b;
}
Rescue(R,C,MR,MC,X);
}
for (auto [a,b]:ans) cout << a << ' ' << b << endl;
}
//*/
void Rescue(int R,int C,int MR,int MC,int X){
--MR;
int x = 0,y = MC-1;
while(x!=MR+1&&y!=-1){
int r = Measure(x+1,y+1);
if (r==X){
Pinpoint(x+1,y+1);
return;
}
if (r<X) ++x;
else --y;
}
x = 0,y = MC-1;
while(x!=MR+1&&y!=C){
int r = Measure(x+1,y+1);
if (r==X){
Pinpoint(x+1,y+1);
return;
}
if (r<X) ++x;
else ++y;
}
x = R-1,y = MC-1;
while(x!=MR+1&&y!=-1){
int r = Measure(x+1,y+1);
if (r==X){
Pinpoint(x+1,y+1);
return;
}
if (r<X) --x;
else --y;
}
x = R-1,y = MC-1;
while(x!=MR-1&&y!=C){
int r = Measure(x+1,y+1);
if (r==X){
Pinpoint(x+1,y+1);
return;
}
if (r<X) --x;
else ++y;
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
600 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
16 |
Incorrect |
0 ms |
412 KB |
Wrong Answer [5] |
17 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
860 KB |
Output is correct |
2 |
Correct |
4 ms |
860 KB |
Output is correct |
3 |
Correct |
3 ms |
860 KB |
Output is correct |
4 |
Correct |
3 ms |
860 KB |
Output is correct |
5 |
Correct |
3 ms |
972 KB |
Output is correct |
6 |
Correct |
3 ms |
860 KB |
Output is correct |
7 |
Correct |
3 ms |
860 KB |
Output is correct |
8 |
Correct |
4 ms |
860 KB |
Output is correct |
9 |
Correct |
3 ms |
860 KB |
Output is correct |
10 |
Correct |
3 ms |
956 KB |
Output is correct |
11 |
Correct |
3 ms |
860 KB |
Output is correct |
12 |
Correct |
3 ms |
860 KB |
Output is correct |
13 |
Correct |
3 ms |
860 KB |
Output is correct |
14 |
Correct |
3 ms |
860 KB |
Output is correct |
15 |
Correct |
3 ms |
860 KB |
Output is correct |
16 |
Correct |
3 ms |
960 KB |
Output is correct |
17 |
Correct |
3 ms |
860 KB |
Output is correct |
18 |
Correct |
3 ms |
968 KB |
Output is correct |
19 |
Correct |
3 ms |
860 KB |
Output is correct |
20 |
Correct |
3 ms |
860 KB |
Output is correct |
21 |
Correct |
3 ms |
860 KB |
Output is correct |
22 |
Correct |
4 ms |
852 KB |
Output is correct |
23 |
Correct |
4 ms |
816 KB |
Output is correct |
24 |
Correct |
3 ms |
964 KB |
Output is correct |
25 |
Correct |
4 ms |
852 KB |
Output is correct |
26 |
Correct |
3 ms |
804 KB |
Output is correct |
27 |
Correct |
3 ms |
860 KB |
Output is correct |
28 |
Correct |
3 ms |
812 KB |
Output is correct |
29 |
Correct |
3 ms |
864 KB |
Output is correct |
30 |
Correct |
3 ms |
860 KB |
Output is correct |
31 |
Correct |
3 ms |
820 KB |
Output is correct |
32 |
Correct |
3 ms |
860 KB |
Output is correct |
33 |
Correct |
3 ms |
860 KB |
Output is correct |
34 |
Correct |
3 ms |
860 KB |
Output is correct |
35 |
Correct |
4 ms |
964 KB |
Output is correct |
36 |
Correct |
4 ms |
860 KB |
Output is correct |
37 |
Correct |
3 ms |
860 KB |
Output is correct |
38 |
Correct |
4 ms |
860 KB |
Output is correct |
39 |
Correct |
3 ms |
860 KB |
Output is correct |
40 |
Correct |
3 ms |
860 KB |
Output is correct |
41 |
Correct |
3 ms |
860 KB |
Output is correct |
42 |
Correct |
3 ms |
860 KB |
Output is correct |
43 |
Correct |
3 ms |
860 KB |
Output is correct |
44 |
Correct |
3 ms |
860 KB |
Output is correct |
45 |
Incorrect |
3 ms |
976 KB |
Wrong Answer [5] |
46 |
Halted |
0 ms |
0 KB |
- |