답안 #72155

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
72155 2018-08-26T05:37:04 Z The quick brown fox jumps over the lazy dog(#2200, khsoo01) 마법 다우징 (FXCUP3_magic) C++17
100 / 100
3 ms 376 KB
#include "dowsing.h"
#include<bits/stdc++.h>
using namespace std;

const int N = 105;

int n, v[N];

void FindTreasure (int _N) {
	n = _N;
	bool D = false;
	for(int i=1;i<=n;i++) {
		v[i] = Detect(i, i);
		if(v[i]) D = true;
	}
	if(D) {
		vector<int> V;
		for(int i=1;i<=n;i++) {
			if(v[i]) V.push_back(i);
		}
		int A = V[0], B = V[1];
		for(int i=1;i<=n;i++) {
			if(i != A && i != B) {
				if(Detect(i, A)) Report(B, A);
				else Report(A, B);
				return;
			}
		}
	}
	else {
		for(int i=1;i<=min(n/2, 49);i++) {
			if(Detect(2*i-1, 2*i)) {
				if(Detect(2*i, 2*i+1)) Report(2*i, 2*i);
				else Report(2*i-1, 2*i-1);
				return;
			}
		}
		for(int i=min(n/2, 49)*2+1;i<n;i++) {
			if(Detect(1, i)) {
				Report(i, i);
				return;
			}
		}
		Report(n, n);
	}
}
# 결과 실행 시간 메모리 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 376 KB Correct : C = 150
9 Correct 3 ms 376 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