Submission #71971

# Submission time Handle Problem Language Result Execution time Memory
71971 2018-08-26T04:22:54 Z End Time(#2161, dotorya, zigui) Magic Dowsing (FXCUP3_magic) C++17
100 / 100
3 ms 404 KB
#include "dowsing.h"
#include <vector>
using namespace std;

typedef pair<int, int> pii;
int getdiff(int x, int y) {
	int t = 1;
	if (x == 1 || y == 1) t = 2;
	if (t == 2 && (x == 2 || y == 2)) t = 3;
	return t;
}
void FindTreasure(int N) {
	vector <int> Vu;
	for (int i = 1; i <= N; i++) {
		if (Detect(i, i)) Vu.push_back(i);
	}
	if (Vu.size() == 2) {
		int t = getdiff(Vu[0], Vu[1]);

		if (Detect(Vu[0], t)) Report(Vu[0], Vu[1]);
		else Report(Vu[1], Vu[0]);
		return;
	}

	int t1 = N - 1, t2 = N, i;
	for (i = 1; i <= (N-1)/2; i++) {
		t1 = i * 2 - 1, t2 = i * 2;
		if (Detect(t1, t2)) break;
	}
	if (i > (N-1)/2) t1 = N - 1, t2 = N;
	
	int x = getdiff(t1, t2);
	if (Detect(t1, x)) Report(t1, t1);
	else Report(t2, t2);
	return;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 252 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 404 KB Correct : C = 150
12 Correct 3 ms 376 KB Correct : C = 149