답안 #72005

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
72005 2018-08-26T04:36:48 Z BBBSNG(#2263, youngyojun, sebinkim, dlalswp25) 마법 다우징 (FXCUP3_magic) C++17
0 / 100
3 ms 376 KB
#include "dowsing.h"

#include <bits/stdc++.h>

using namespace std;

int A[111], B[111], P[111], Q[111];

void FindTreasure(int N)
{
	int i, f1, f2, a, b, x, y, x1, x2, y1, y2, k;
	
	if(N < 75){
		for(i=1; i<=N; i++){
			A[i] = Detect(i, 1);
			if(A[i] != A[1]) x = i;
		}
		for(i=1; i<=N; i++){
			B[i] = Detect(1, i);
			if(B[i] != A[1]) y = i;
		}
		
		if(A[1] != A[2] && A[1] != A[3]) x = 1;
		if(B[1] != B[2] && B[1] != B[3]) y = 1;
		
		Report(x, y);
		
		return;
		
	}
	
	srand(time(0));
	
	for(i=0; i<N; i++){
		P[i] = i + 1;
		Q[i] = i + 1;
	}
	
	for(i=1; i<=10000; i++){
		a = rand() % N;
		b = rand() % N;
		swap(P[a], P[b]);
		
		a = rand() % N;
		b = rand() % N;
		swap(Q[a], Q[b]);
	}
	
	x1 = -1;
	
	for(i=0; i<N; i++){
		if(Detect(P[i], Q[i])){
			if(x1 == -1) x1 = P[i], y1 = Q[i];
			else x2 = P[i], y2 = Q[i];
		}
	}
	
	for(i=1; i<=N; i++) if(i != x1 && i != x2) break;
	
	if(Detect(i, y2)) Report(x1, y2);
	else Report(x2, y1);
}

Compilation message

dowsing.cpp: In function 'void FindTreasure(int)':
dowsing.cpp:11:9: warning: unused variable 'f1' [-Wunused-variable]
  int i, f1, f2, a, b, x, y, x1, x2, y1, y2, k;
         ^~
dowsing.cpp:11:13: warning: unused variable 'f2' [-Wunused-variable]
  int i, f1, f2, a, b, x, y, x1, x2, y1, y2, k;
             ^~
dowsing.cpp:11:45: warning: unused variable 'k' [-Wunused-variable]
  int i, f1, f2, a, b, x, y, x1, x2, y1, y2, k;
                                             ^
dowsing.cpp:60:11: warning: 'y2' may be used uninitialized in this function [-Wmaybe-uninitialized]
  if(Detect(i, y2)) Report(x1, y2);
     ~~~~~~^~~~~~~
dowsing.cpp:61:13: warning: 'y1' may be used uninitialized in this function [-Wmaybe-uninitialized]
  else Report(x2, y1);
       ~~~~~~^~~~~~~~
dowsing.cpp:61:13: warning: 'x2' may be used uninitialized in this function [-Wmaybe-uninitialized]
dowsing.cpp:26:9: warning: 'x' may be used uninitialized in this function [-Wmaybe-uninitialized]
   Report(x, y);
   ~~~~~~^~~~~~
dowsing.cpp:26:9: warning: 'y' may be used uninitialized in this function [-Wmaybe-uninitialized]
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Correct : C = 6
2 Correct 2 ms 256 KB Correct : C = 6
3 Runtime error 3 ms 376 KB Execution failed because the return code was nonzero
4 Halted 0 ms 0 KB -