QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#295878 | #1418. Mountain Rescue Team | 17 | 0 | 0ms | 3772kb | C++20 | 1.4kb | 2024-01-01 13:32:40 | 2024-01-01 13:32:41 |
answer
#include <bits/stdc++.h>
using namespace std;
#include "grader.h"
pair<int, int> Rescue2(int Rl, int Rr, int Cl, int Cr, int dx, int dy, int MR, int MC, int X){
int c = 0;
map<int, pair<int, int>> m;
int x = MR, y = MC;
while(abs(dx)+abs(dy) != 0){
m[abs(x-MR)+abs(y-MC)] = {x, y};
if(x+dx < Rl || x+dx > Rr){
dx = 0;
}
if(y+dy < Cl || y+dy > Cr){
dy = 0;
}
x += dx;
y += dy;
c = max(c, abs(x-MR)+abs(y-MC));
}
int l = 0, r = c;
while(r-l > 1){
int mid = (l+r)/2;
int x = m[mid].first, y = m[mid].second;
int h = Measure(x, y);
if(h == X){
return {x, y};
}
if(h < X) r = mid;
else l = mid;
}
for(int i = Rl; i <= Rr; i++){
for(int j = Cl; j <= Cr; j++){
if(i == m[r].first || j == m[r].second){
int h = Measure(i, j);
if(h == X) return {i, j};
}
}
}
return {-1, -1};
}
void Rescue(int R, int C, int MR, int MC, int X){
pair<int, int> p;
p = Rescue2(1, MR, 1, MC, -1, -1, MR, MC, X);
if(p != make_pair(-1, -1)) Pinpoint(p.first, p.second);
p = Rescue2(1, MR, MC, C, -1, +1, MR, MC, X);
if(p != make_pair(-1, -1)) Pinpoint(p.first, p.second);
p = Rescue2(MR, R, 1, MC, +1, -1, MR, MC, X);
if(p != make_pair(-1, -1)) Pinpoint(p.first, p.second);
p = Rescue2(MR, R, MC, C, +1, +1, MR, MC, X);
if(p != make_pair(-1, -1)) Pinpoint(p.first, p.second);
}
详细
Subtask #1:
score: 0
Runtime Error
Test #1:
score: 20
Accepted
time: 0ms
memory: 3772kb
input:
1 1 1 1 1 1
output:
Accepted
Test #2:
score: -20
Runtime Error
input:
2 2 2 2 1 1 2 3 4
output:
Wrong Answer [1]
Subtask #2:
score: 0
Skipped
Dependency #1:
0%