답안 #110495

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
110495 2019-05-11T03:47:22 Z tjd229 마법 다우징 (FXCUP3_magic) C++14
100 / 100
3 ms 444 KB
#include "dowsing.h"

void FindTreasure(int N) {
	int i, j;
	int x[2];
	int f = 0;
	for (i = 1; i <= N && f<2; ++i) {
		if (Detect(i, i)) x[f++] = i;
	}
	int xo = 1;
	if (!f) {
		for (i = 1; i < N - 1 && f < 2; i += 2) {
			if (Detect(i + 1, i)) {
				x[f++] = i;
				x[f++] = 1 + i;
			}
		}
		if (!f) x[1] = N, x[0] = N - 1;
		xo = 0;
	}
	int y = 1;
	if (y == x[0]) ++y;
	if (y == x[1]) ++y;
	if (Detect(x[0], y)) {
		Report(x[0], x[0^xo]);
		return;
	}
	Report(x[1], x[1^xo]);
}

Compilation message

dowsing.cpp: In function 'void FindTreasure(int)':
dowsing.cpp:4:9: warning: unused variable 'j' [-Wunused-variable]
  int i, j;
         ^
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 256 KB Correct : C = 5
2 Correct 2 ms 256 KB Correct : C = 4
3 Correct 3 ms 376 KB Correct : C = 149
4 Correct 3 ms 376 KB Correct : C = 100
5 Correct 3 ms 376 KB Correct : C = 150
6 Correct 3 ms 376 KB Correct : C = 101
7 Correct 3 ms 376 KB Correct : C = 149
8 Correct 3 ms 396 KB Correct : C = 150
9 Correct 3 ms 444 KB Correct : C = 150
10 Correct 3 ms 376 KB Correct : C = 150
11 Correct 3 ms 376 KB Correct : C = 150
12 Correct 3 ms 376 KB Correct : C = 149