QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#216590#5134. Jagged SkylineMovingUp#WA 1ms3672kbC++141.0kb2023-10-15 20:14:582023-10-15 20:14:59

Judging History

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

  • [2023-10-15 20:14:59]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3672kb
  • [2023-10-15 20:14:58]
  • 提交

answer

#include <algorithm>
#include <iostream>
#include <random>
#include <vector>

using namespace std;

mt19937 mt(69);

bool isBuilding(int x, int64_t y) {
  cout << "? " << x << " " << y << endl;
  cout.flush();

  string response;
  cin >> response;

  return (response == "building");
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);

  int w;
  int64_t h;
  cin >> w >> h;

  vector<int> columns(w);
  for (int i = 1; i <= w; i++) {
    columns[i - 1] = i;
  }

  shuffle(columns.begin(), columns.end(), mt);

  int colHighest = -1;
  int64_t currHighest = 0;
  for (auto col : columns) {
    if (!isBuilding(col, currHighest + 1)) {
      continue;
    }

    int64_t low = currHighest + 2, high = (int64_t)1e18;
    while (low <= high) {
      int64_t mid = (low + high) / 2;

      if (isBuilding(col, mid))
        low = mid + 1;
      else
        high = mid - 1;
    }

    currHighest = low - 1;
    colHighest = col;
  }

  cout << "! " << colHighest << " " << currHighest << endl;
  cout.flush();
}

詳細信息

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 3672kb

input:

1 1
sky

output:

? 1 1
! -1 0

result:

wrong answer Integer parameter [name=xans] equals to -1, violates the range [1, 1]