QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#295877 | #1418. Mountain Rescue Team | 17 | 0 | 0ms | 3716kb | C++20 | 1.4kb | 2024-01-01 13:31:25 | 2024-01-01 13:31:26 |
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;
}
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);
}
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: 3716kb
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:
Unauthorized output
Subtask #2:
score: 0
Skipped
Dependency #1:
0%