QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#295880#1418. Mountain Rescue Team170 0ms3664kbC++201.5kb2024-01-01 13:37:102024-01-01 13:37:10

Judging History

你现在查看的是最新测评结果

  • [2024-01-01 13:37:10]
  • 评测
  • 测评结果:0
  • 用时:0ms
  • 内存:3664kb
  • [2024-01-01 13:37:10]
  • 提交

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){
  if(Measure(MR, MC) == X){
	Pinpoint(MR, MC);
	return;
  }
  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);
	return;
  }
  p = Rescue2(1, MR, MC, C, -1, +1, MR, MC, X);
  if(p != make_pair(-1, -1)){
	Pinpoint(p.first, p.second);
	return;
  }
  p = Rescue2(MR, R, 1, MC, +1, -1, MR, MC, X);
  if(p != make_pair(-1, -1)){
	Pinpoint(p.first, p.second);
	return;
  }
  p = Rescue2(MR, R, MC, C, +1, +1, MR, MC, X);
  if(p != make_pair(-1, -1)){
	Pinpoint(p.first, p.second);
	return;
  }
}

詳細信息

Subtask #1:

score: 0
Runtime Error

Test #1:

score: 20
Accepted
time: 0ms
memory: 3664kb

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%