#include "dowsing.h"
#include <bits/stdc++.h>
using namespace std;
int y = 0, n;
void yeah(int x, int y)
{
Report(x, y);
}
void f(int s, int e)
{
if(s == e) yeah(s, s);
int a = Detect(s, s);
int b = Detect(e, e);
if(a == 1 && b == 1){
int c = Detect(s, e);
if(c == 1) yeah(e, s);
else yeah(s, e);
}
else if(a == 1){
int i, j;
for(i=s+1; i<e; i++) if(Detect(i, i)) break;
//(s, i) or (i, s)
for(j=1; j<=n; j++) if(j != s && j != i) break;
if(Detect(s, j)) yeah(s, i);
else yeah(i, s);
}
else if(b == 1){
int i, j;
for(i=s+1; i<e; i++) if(Detect(i, i)) break;
//(e, i) or (i, e)
for(j=1; j<=n; j++) if(j != e && j != i) break;
if(Detect(e, j)) yeah(e, i);
else yeah(i, e);
}
else{
if(s + 1 == e){
int i;
for(i=1; i<=n; i++) if(i != s && i != e) break;
if(Detect(s, i)) Report(s, s);
else Report(e, e);
return;
}
int c = Detect(s, e);
if(c == 1){
int i;
for(i=1; i<=n; i++) if(i != s && i != e) break;
if(Detect(s, i)) Report(s, s);
else Report(e, e);
}
else f(s + 1, e - 1);
}
}
void FindTreasure(int N) { n = N; f(1, N); }
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
352 KB |
Correct : C = 4 |
2 |
Correct |
2 ms |
256 KB |
Correct : C = 4 |
3 |
Correct |
3 ms |
376 KB |
Correct : C = 148 |
4 |
Correct |
3 ms |
376 KB |
Correct : C = 148 |
5 |
Correct |
3 ms |
376 KB |
Correct : C = 150 |
6 |
Correct |
3 ms |
376 KB |
Correct : C = 149 |
7 |
Runtime error |
3 ms |
376 KB |
Execution failed because the return code was nonzero |
8 |
Halted |
0 ms |
0 KB |
- |