#include "dowsing.h"
#include<queue>
using namespace std;
void FindTreasure(int N) {
queue<int> q;
for (int i = 1; i < N; i ++)
if (Detect(i, i)) {
q.push(i);
}
if (q.size() == 1)
q.push(N);
if (q.size() == 2) {
int i, j;
i = q.front(); q.pop();
j = q.front();
int t = j + 1;
if (t > N)
t = 1;
if (t == i)
t = j - 1;
if (t == 0)
t = N;
if (Detect(t, j))
Report(i, j);
else
Report(j, i);
return;
}
else {
for (int i = N, j = 1; j <= N/2; i --, j ++) {
if (Detect(i, j)) {
int t = i + 1;
if (t > N)
t = 1;
if (t == j)
t = i - 1;
if (t == 0)
t = N;
if (Detect(i, t))
Report(i, i);
else
Report(j, j);
return;
}
}
Report((N+1)/2, (N+1)/2);
}
return;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
256 KB |
Correct : C = 4 |
2 |
Correct |
2 ms |
256 KB |
Correct : C = 3 |
3 |
Correct |
3 ms |
380 KB |
Correct : C = 148 |
4 |
Correct |
3 ms |
376 KB |
Correct : C = 99 |
5 |
Correct |
3 ms |
376 KB |
Correct : C = 150 |
6 |
Correct |
3 ms |
376 KB |
Correct : C = 100 |
7 |
Correct |
3 ms |
376 KB |
Correct : C = 147 |
8 |
Correct |
3 ms |
376 KB |
Correct : C = 150 |
9 |
Correct |
3 ms |
376 KB |
Correct : C = 150 |
10 |
Correct |
3 ms |
376 KB |
Correct : C = 101 |
11 |
Correct |
3 ms |
376 KB |
Correct : C = 104 |
12 |
Correct |
3 ms |
376 KB |
Correct : C = 101 |