#include "grader.h"
#include <bits/stdc++.h>
using namespace std;
void Rescue(int R, int C, int RS, int CS, int X){
	int n=max(RS-1,R-RS),m=max(CS-1,C-CS);
	int l=0,r=n+m;
	while(l<r){
		int mid=(l+r+1)/2;
		int x=RS+min(n,mid),y=CS+max(0,mid-n);
		if(x>R) x=RS-min(n,mid);
		if(y>C) y=CS-max(0,mid-n);
		if(Measure(x,y)<X)
			r=mid+1;
		else l=mid;
	}
	for(int i=1;i<=R;i++){
		for(int j=1;j<=C;j++){
			if(abs(i-RS)+abs(j-CS)==l || abs(i-RS)+abs(j-CS)==l+1){
				if(Measure(i,j)==X){
					Pinpoint(i,j);
					return;
				}
			}
		}
	}
}
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... |