# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
328589 | seedkin | Magic Dowsing (FXCUP3_magic) | C11 | 2 ms | 364 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "dowsing.h"
#include <stdio.h>
void FindTreasure(int N) {
int find = 0;
int findX[10];
int findY[10];
int targetX = 0;
int targetY = 0;
int half = (N) / 2 + 1;
for(int i = half; i <= N; i++) {
// printf("%d %d\n", i, i - half + 1);
int r = Detect(i, i - half + 1);
if(r) {
findX[find] = i;
findY[find] = i - half + 1;
find++;
}
r = Detect(i - half + 1, i);
if(r) {
findX[find] = i - half + 1;;
findY[find] = i;
find++;
}
}
// printf("%d \n", find);
if(find == 0) {
int r = 0;
for(int i = 0; i < half - 2; i++) {
r = Detect(i+1, i+1);
if(r) {
targetX = i+1;
targetY = i+1;
break;
}
}
if(N % 2 && r == 0) {
r = Detect(half-1, half-1);
if(r) {
targetX = half-1;
targetY = half-1;
}
}
if( r == 0) {
if(N % 2) {
targetX = half;
targetY = half;
} else {
targetX = half-1;
targetY = half-1;
}
}
r = Detect(targetX+1, targetY);
if(r) {
Report(targetY >= half ? targetY - half + 1 : half + targetY - 1, targetY);
} else {
Report(targetX, targetX >= half ? targetX - half + 1 : half + targetX - 1);
}
return;
} else if ( find == 1 ) {
if(findX[0] == 1 || findX[0] == N) {
Report(N + 1 - findX[0], findY[0]);
} else {
Report(findX[0], N + 1 - findY[0]);
}
} else if ( find == 2 ) {
if( findX[0] != 1 && findX[0] != N) {
int r = Detect(findX[0]+1, findY[0]);
r |= Detect(findX[0]-1, findY[0]);
if(r == 0) {
Report(findX[0], findY[1]);
} else {
Report(findX[1], findY[0]);
}
} else {
int r = Detect(findX[0], findY[0]+1);
r |= Detect(findX[0], findY[0]-1);
if(r == 0) {
Report(findX[1], findY[0]);
} else {
Report(findX[0], findY[1]);
}
}
return;
} else if ( find == 3 ) {
if(findX[0] == findX[2]) {
Report(findX[0], findY[1]);
} else {
Report(findX[1], findY[0]);
}
return;
} else if ( find == 4 ) {
Report(half, half);
return;
}
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |