QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#202969 | #866. Display of Springs | isaunoya | WA | 1ms | 3544kb | C++23 | 2.8kb | 2023-10-06 14:24:10 | 2023-10-06 14:24:12 |
Judging History
answer
#include <bits/stdc++.h>
#ifndef LOCAL
#define debug(...) 42
#else
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#endif
#define rep1(a) for (int i = 0; i < a; i++)
#define rep2(i, a) for (int i = 0; i < a; i++)
#define rep3(i, a, b) for (int i = a; i < b; i++)
#define rep4(i, a, b, c) for (int i = a; i < b; i += c)
#define overload4(a, b, c, d, e, ...) e
#define rep(...) overload4(__VA_ARGS__, rep4, rep3, rep2, rep1)(__VA_ARGS__)
#define pb emplace_back
using namespace std;
template <typename T, typename T2> void cmin(T &x, const T2 &y) {
x = x < y ? x : y;
}
template <typename T, typename T2> void cmax(T &x, const T2 &y) {
x = x > y ? x : y;
}
using ll = long long;
using vi = vector<int>;
using pii = pair<int, int>;
template <class T> using vc = vector<T>;
template <class T> using pq = priority_queue<T>;
template <class T> using pqg = priority_queue<T, vector<T>, greater<T>>;
mt19937 rng(time(NULL));
const int inf = 1000000000;
const ll lnf = 1000000000000000000;
#define sz(x) int((x).size())
#define all(x) begin(x), end(x)
#define fi first
#define se second
int get(int a, int b, int w) {
cout << "? " << a << " " << b << " " << w << endl;
string s;
cin >> s;
if (s == "FIRST") {
return a;
} else {
return b;
}
}
const int N = 1e5;
int id[N * 4];
void update(int l, int r, int p, int x) {
if (!id[p]) {
id[p] = x;
return;
}
if (l == r) {
if (get(id[p], x, l) == x) {
id[p] = x;
}
return;
}
int m = (l + r) / 2;
int ql = get(id[p], x, l);
int qr = get(id[p], x, r);
if (ql == id[p] && qr == id[p]) {
return;
}
if (ql == x && qr == x) {
id[p] = x;
return;
}
int qm = get(id[p], x, m);
if (qm == x) {
int y = id[p];
id[p] = x;
if (ql == y)
update(l, m, p * 2, y);
if (qr == y)
update(m + 1, r, p * 2 + 1, y);
return;
}
if (qm == id[p]) {
if (ql == x)
update(l, m, p * 2, x);
if (qr == x)
update(m + 1, r, p * 2 + 1, x);
return;
}
}
int query(int l, int r, int p, int x) {
if (l == r) {
return id[p];
}
int m = (l + r) / 2;
int y;
if (x <= m)
y = query(l, m, p * 2, x);
else
y = query(m + 1, r, p * 2 + 1, x);
return get(id[p], y, x);
}
void solve() {
int n;
cin >> n;
for (int b = 0; b < n; b++) {
update(1, N, 1, b);
}
cout << "!" << endl;
while (true) {
string s;
cin >> s;
if (s == "QUESTION") {
int x;
cin >> x;
cout << query(1, N, 1, x) << endl;
} else {
return;
}
}
}
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int t = 1;
// cin >> t;
while (t--) {
solve();
}
return 0;
}
详细
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 3544kb
input:
3 FIRST SECOND SECOND QUESTION 2 EQUAL EQUAL EQUAL EQUAL EQUAL EQUAL EQUAL EQUAL EQUAL EQUAL EQUAL EQUAL EQUAL EQUAL EQUAL FIRST SECOND
output:
? 1 2 1 ? 1 2 100000 ? 1 2 50000 ! ? 0 0 2 ? 0 0 2 ? 0 0 2 ? 0 0 2 ? 0 0 2 ? 0 0 2 ? 0 0 2 ? 0 0 2 ? 0 0 2 ? 0 0 2 ? 0 0 2 ? 0 0 2 ? 0 0 2 ? 0 0 2 ? 0 0 2 ? 1 0 2 ? 2 1 2 1
result:
wrong answer Invalid input: invalid query token