답안 #72195

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
72195 2018-08-26T05:54:22 Z 김동현보다 잘함(#2226, tlwpdus) 마법 다우징 (FXCUP3_magic) C++17
100 / 100
3 ms 376 KB
#include "dowsing.h"
#include<bits/stdc++.h>

using namespace std;

int mini(int a, int b) {
    int arr[3] = {1,1,1};
    arr[min(a,2)] = 0; arr[min(b,2)] = 0;
    for (int i=0;i<3;i++)if (arr[i]) return i;
    return 0;
}

void chk(int c, int d) {
    if (c==d) Report(c+1,d+1);
    else if (Detect(c+1,mini(c,d)+1)) Report(c+1,d+1);
    else Report(d+1,c+1);
}

void rchk(int c, int d) {
    if (c==d) Report(c+1,d+1);
    else if (Detect(c+1,mini(c,d)+1)) Report(c+1,c+1);
    else Report(d+1,d+1);
}

void FindTreasure(int N) {
    int i, c = -1, d = -1;
    for (i=0;i<N;i++){
        if (Detect(i+1,i+1)) {
            if (c<0) c = i;
            else d = i;
        }
    }
    if (c>=0) {
        chk(c,d);
        return;
    }
    for (i=0;i<(N-1)/2;i++) {
        if (Detect(i+1,N-i)) {
            rchk(i,N-1-i);
            return;
        }
    }
    rchk((N-1)/2,N-1-(N-1)/2);
}
# 결과 실행 시간 메모리 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 376 KB Correct : C = 150
6 Correct 3 ms 376 KB Correct : C = 101
7 Correct 3 ms 376 KB Correct : C = 148
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 = 102
11 Correct 3 ms 376 KB Correct : C = 105
12 Correct 3 ms 376 KB Correct : C = 102