QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#216590 | #5134. Jagged Skyline | MovingUp# | WA | 1ms | 3672kb | C++14 | 1.0kb | 2023-10-15 20:14:58 | 2023-10-15 20:14:59 |
Judging History
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]