Submission #74344

# Submission time Handle Problem Language Result Execution time Memory
74344 2018-08-31T10:54:07 Z khsoo01 Magic Dowsing (FXCUP3_magic) C++11
100 / 100
3 ms 380 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);
	}
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Correct : C = 5
2 Correct 2 ms 376 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 380 KB Correct : C = 150
12 Correct 3 ms 376 KB Correct : C = 149