답안 #328585

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
328585 2020-11-17T07:17:04 Z seedkin 마법 다우징 (FXCUP3_magic) C
0 / 100
1 ms 364 KB
#include "dowsing.h"



void FindTreasure(int N) {

	int find = 0;

	int findX[10];

	int findY[10];

	int targetX = 0;

	int targetY = 0;



	int half = (N+1) / 2;

	for(int i = half; i <= N; i++) {

		int r = Detect(i, i - half + 1);

		if(r) {

			findX[find] = i;

			findY[find] = i - half + 1;

			r++;

		}

		r = Detect(i - half + 1, i);

		if(r) {

			findX[find] = i - half + 1;;

			findY[find] = i;

			r++;

		}

	}



	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 ) {



	} else if ( find == 2 ) {

		int r = Detect(findX[0], findY[1]);

		if(r == 0) {

			Report(findX[0], findY[1]);

		} else {

			Report(findX[1], findY[0]);

		}

		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;

	}



}

# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Correct : C = 6
2 Runtime error 0 ms 364 KB Execution failed because the return code was nonzero
3 Halted 0 ms 0 KB -