QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#295839 | #1418. Mountain Rescue Team | 17 | 0 | 0ms | 3752kb | C++20 | 914b | 2024-01-01 12:31:44 | 2024-01-01 12:31:46 |
answer
#include <bits/stdc++.h>
using namespace std;
#include "grader.h"
void Rescue(int R, int C, int MR, int MC, int X){
int l = 0, r = max(MR, R-MR+1) + max(MC, C-MR+1) - 2;
while(r-l > 2){
int mid = (l+r)/2;
int x = MR, y = MC;
int d = mid;
if(MR < R-MR+1){
x += min(R-MR, d);
d -= min(R-MR, d);
}else{
x -= min(MR-1, d);
d -= min(MR-1, d);
}
if(MC < C-MC+1){
y += min(C-MC, d);
d -= min(C-MC, d);
}else{
y -= min(MC-1, d);
d -= min(MC-1, d);
}
int h = Measure(x, y);
if(h == X){
Pinpoint(x, y);
return;
}
if(h < X) r = mid;
else l = mid-1;
}
for(int i = 1; i <= R; i++){
for(int j = 1; j <= C; j++){
int k = abs(i-MR)+abs(j-MC);
if(k == l || k == r){
int h = Measure(i, j);
if(h == X) Pinpoint(i, j);
}
}
}
}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 0
Runtime Error
Test #1:
score: 20
Accepted
time: 0ms
memory: 3696kb
input:
1 1 1 1 1 1
output:
Accepted
Test #2:
score: 0
Accepted
time: 0ms
memory: 3752kb
input:
2 2 2 2 1 1 2 3 4
output:
Accepted
Test #3:
score: -20
Runtime Error
input:
2 2 2 2 2 1 2 3 4
output:
Unauthorized output
Subtask #2:
score: 0
Skipped
Dependency #1:
0%