답안 #72403

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
72403 2018-08-26T07:46:38 Z cat > /dev/null(#2231, lobo_prix, jms100300, enochjung) 마법 다우징 (FXCUP3_magic) C++17
100 / 100
3 ms 380 KB
#include "dowsing.h"
#include<queue>
using namespace std;

void FindTreasure(int N) {
    queue<int> q;
    for (int i = 1; i < N; i ++)
        if (Detect(i, i)) {
            q.push(i);
        }

    if (q.size() == 1)
        q.push(N);

    if (q.size() == 2) {
        int i, j;
        i = q.front(); q.pop();
        j = q.front();

        int t = j + 1;
        if (t > N)
            t = 1;
        if (t == i)
            t = j - 1;
        if (t == 0)
            t = N;

        if (Detect(t, j))
            Report(i, j);
        else
            Report(j, i);
        return;
    }
    else {
        for (int i = N, j = 1; j <= N/2; i --, j ++) {
            if (Detect(i, j)) {
                int t = i + 1;
                if (t > N)
                    t = 1;
                if (t == j)
                    t = i - 1;
                if (t == 0)
                    t = N;

                if (Detect(i, t))
                    Report(i, i);
                else
                    Report(j, j);

                return;
            }
        }
        Report((N+1)/2, (N+1)/2);
    }


    return;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 256 KB Correct : C = 4
2 Correct 2 ms 256 KB Correct : C = 3
3 Correct 3 ms 380 KB Correct : C = 148
4 Correct 3 ms 376 KB Correct : C = 99
5 Correct 3 ms 376 KB Correct : C = 150
6 Correct 3 ms 376 KB Correct : C = 100
7 Correct 3 ms 376 KB Correct : C = 147
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 = 101
11 Correct 3 ms 376 KB Correct : C = 104
12 Correct 3 ms 376 KB Correct : C = 101