이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
map<array<int, 3>, int> Ma;
int N, M, K;
int query_cnt = 0;
int query(int a, int b, int c) {
if(!(1<=a&&a<=N&&1<=b&&b<=M&&1<=c&&c<=K)) return -1;
if(Ma.count({a, b, c})) return Ma[{a, b, c}];
query_cnt++;
cout << "? " << a << ' ' << b << ' ' << c << endl;
int d;
cin >> d;
Ma[{a, b, c}] = d;
return d;
}
void answer(int a, int b, int c) {
cout << "! " << a << ' ' << b << ' ' << c << endl;
return;
}
int fibo[44];
void subtask_12() {
int s = 1, e = fibo[30];
int x = fibo[28], y = fibo[29];
while(s<=e) {
if(s==e) {
answer(s, 1, 1);
return;
}
if(s+1==e) {
if(query(s, 1, 1) >= query(e, 1, 1)) {
answer(s, 1, 1);
return;
}
else {
answer(e, 1, 1);
return;
}
}
if(s+3>=e) {
int mid = (s + e + 1) / 2;
if(query(mid, 1, 1) < query(mid+1, 1, 1)) {
s = mid + 1;
}
else {
e = mid;
}
continue;
}
if(query(x, 1, 1) >= query(y, 1, 1)) {
e = y;
y = x;
x = (s+e) - y;
}
else {
s = x;
x = y;
y = (s+e) - x;
}
}
}
void subtask_34() {
}
void subtask_56() {
}
signed main() {
fibo[0] = fibo[1] = 1;
for(int i = 2 ; i <= 43; i++) {
fibo[i] = fibo[i-1] + fibo[i-2];
//cout << i << " : " << fibo[i] << '\n';
}
int Q;
cin >> N >> M >> K >> Q;
if(M==1 && K == 1 && N == 1000000) {
subtask_12();
}
if(K==1 && N==M) {
subtask_34();
}
if(K==N && K==M) {
subtask_56();
}
cout << query_cnt;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |