Submission #72361

# Submission time Handle Problem Language Result Execution time Memory
72361 2018-08-26T07:28:09 Z 우리는 진실을 잊고 살잖아~~~(#2195, leejseo, king114) Magic Dowsing (FXCUP3_magic) C++17
100 / 100
3 ms 380 KB
#include "dowsing.h"
//#include <iostream>
//using namespace std;

bool B[101][101];

void FindTreasure(int N) {
	int x, y, cnt=0;
	for (int i=1; i<=N; i++){
		if (Detect(i, i)){
			++cnt;
			if (cnt == 2){
				y=i;
				break;
			}
			x=i;
			continue;
		}
	}
	if (cnt > 0){
		int c;
		if (y != x+1) c = x+1;
		else{
			if (y != N) c = N;
			else c = N-1;
		}	
		if (Detect(x, c)){
			Report(x, y);
			return;
		}
		Report(y, x);
		return;
	}
	cnt=0;
	for (int i=1; i<=(N-1)/2; i++){
		if (Detect(i, N-i+1)){
			++cnt;
			x = i;
			y = N-i+1;
			break;
		}
	}
	if (cnt == 0) x = (N+1)/2, y = x+1;
	int c;
	if (y != x+1) c = x+1;
	else{
		if (y != N) c = N;
		else c = N-1;
	}	
	if (Detect(x, c)) Report(x, x);
	else Report(y, y);
	return;
}

Compilation message

dowsing.cpp: In function 'void FindTreasure(int)':
dowsing.cpp:24:4: warning: 'y' may be used uninitialized in this function [-Wmaybe-uninitialized]
    if (y != N) c = N;
    ^~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 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 380 KB Correct : C = 150
6 Correct 3 ms 376 KB Correct : C = 101
7 Correct 3 ms 352 KB Correct : C = 149
8 Correct 3 ms 372 KB Correct : C = 150
9 Correct 3 ms 376 KB Correct : C = 150
10 Correct 3 ms 376 KB Correct : C = 102
11 Correct 3 ms 376 KB Correct : C = 105
12 Correct 3 ms 376 KB Correct : C = 102