답안 #27187

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
27187 2017-07-10T04:36:54 Z wangyenjen Park (JOI17_park) C++14
20 / 100
166 ms 2124 KB
// Author: Wang, Yen-Jen
#include "park.h"
#include <bits/stdc++.h>

using namespace std;

static int N;
static int place[1400];

inline static void subtask1() {
    memset(place , 0 , sizeof(place));
    for(int i = 0; i < N; i++) {
        for(int j = i + 1; j < N; j++) {
            place[i] = 1;
            place[j] = 1;
            if(Ask(i , j , place)) Answer(i , j);
            place[i] = 0;
            place[j] = 0;
        }
    }
}

inline static void subtask2() {
    for(int i = 0; i < N; i++) place[i] = 1;
    vector<int> vec;
    for(int i = 1; i < N - 1; i++) vec.push_back(i);
    stable_sort(vec.begin() , vec.end() , [&](const int x , const int y) {
        place[x] = 0;
        int t = Ask(0 , y , place);
        place[x] = 1;
        return t == 0;
    });
    for(int i = 1; i < (int)vec.size(); i++) Answer(min(vec[i - 1] , vec[i]) , max(vec[i - 1] , vec[i]));
    Answer(0 , vec[0]);
    Answer(vec.back() , N - 1);
}

inline static void subtask3() {
    vector<int> lev[10];
    for(int i = 0; i < N; i++) place[i] = 1;
    vector<int> vec;
    for(int i = 1; i < N; i++) vec.push_back(i);
    stable_sort(vec.begin() , vec.end() , [&](const int x , const int y) {
        place[x] = 0;
        int t = Ask(0 , y , place);
        place[x] = 1;
        return t == 0;
    });
    lev[0].push_back(0);
    for(int x : vec) {
        bool flag = 0;
        for(int i = 8; i >= 1; i--) {
            for(int j = 0; j < N; j++) place[j] = 1;
            for(int y : lev[i]) place[y] = 0;
            if(!Ask(0 , x , place)) {
                flag = 1;
                int lb = 0 , rb = (int)lev[i].size() - 1;
                while(lb < rb) {
                    int mid = (lb + rb) >> 1;
                    for(int j = 0; j < N; j++) place[j] = 1;
                    for(int j = lb; j <= mid; j++) place[lev[i][j]] = 0;
                    if(Ask(0 , x , place)) lb = mid + 1;
                    else rb = mid;
                }
                lev[i + 1].push_back(x);
                Answer(min(lev[i][lb] , x) , max(lev[i][lb] , x));
                break;
            }
        }
        if(!flag) {
            lev[1].push_back(x);
            Answer(0 , x);
        }
    }
}

void Detect(int T , int _N) {
    N = _N;
    if(N == 1) return;
    else if(N == 2) {
        Answer(0 , 1);
        return;
    }
    if(T == 1) subtask1();
    else if(T == 2) subtask2();
    else subtask3();
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 2124 KB Output is correct
2 Correct 6 ms 2124 KB Output is correct
3 Correct 6 ms 2124 KB Output is correct
4 Correct 6 ms 2124 KB Output is correct
5 Correct 6 ms 2124 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 163 ms 2124 KB Output is correct
2 Correct 56 ms 2124 KB Output is correct
3 Correct 56 ms 2124 KB Output is correct
4 Correct 153 ms 2124 KB Output is correct
5 Correct 156 ms 2124 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 86 ms 2124 KB Wrong Answer[2]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 43 ms 2124 KB Wrong Answer[2]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 166 ms 2124 KB Wrong Answer[2]
2 Halted 0 ms 0 KB -