답안 #125389

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
125389 2019-07-05T07:31:18 Z 송준혁(#3062) Park (JOI17_park) C++14
27 / 100
305 ms 640 KB
#include <bits/stdc++.h>
#include "park.h"
using namespace std;

static int N;
static int P[2020];
static vector<int> V[2020];
static int Q[2020];

void f(int u){
    vector<int> C;
    for (int i=0; i<N; i++) Q[i] = 0;
    for (int &v : V[u]){
        Q[u] = Q[v] = 1;
        if (u < v){
            if (Ask(u, v, Q)){
                C.push_back(v);
                P[v] = u;
                Q[u] = Q[v] = 0;
                v = -1;
            }
        }
        else{
            if (Ask(v, u, Q)){
                C.push_back(v);
                P[v] = u;
                Q[u] = Q[v] = 0;
                v = -1;
            }
        }
        Q[u] = Q[v] = 0;
    }
    for (int i=0; i<N; i++) Q[i] = 1;
    for (int v : V[u]){
        if (v == -1) continue;
        int L = 0, R = C.size()-1, k;
        while (L<=R){
            int mid = (L+R)/2;
            for (int i=0; i<=mid; i++) Q[C[i]] = 0;
            if (u < v){
                if (Ask(u, v, Q)) L = mid+1;
                else k = mid, R = mid-1;
            }
            else{
                if (Ask(v, u, Q)) L = mid+1;
                else k = mid, R = mid-1;
            }
            for (int i=0; i<=mid; i++) Q[C[i]] = 1;
        }
        V[C[k]].push_back(v);
    }
    for (int v : C) f(v);
}

void Detect(int T, int n) {
    N = n;
    for (int i=1; i<N; i++) V[0].push_back(i);
    f(0);
    for (int i=1; i<N; i++){
        if (P[i] < i) Answer(P[i], i);
        else Answer(i, P[i]);
    }
}

Compilation message

park.cpp: In function 'void f(int)':
park.cpp:50:14: warning: 'k' may be used uninitialized in this function [-Wmaybe-uninitialized]
         V[C[k]].push_back(v);
              ^
# 결과 실행 시간 메모리 Grader output
1 Runtime error 3 ms 636 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 305 ms 636 KB Wrong Answer[5]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 139 ms 556 KB Output is correct
2 Correct 169 ms 556 KB Output is correct
3 Correct 132 ms 504 KB Output is correct
4 Correct 129 ms 640 KB Output is correct
5 Correct 121 ms 632 KB Output is correct
6 Correct 137 ms 604 KB Output is correct
7 Correct 133 ms 552 KB Output is correct
8 Correct 156 ms 552 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 138 ms 512 KB Output is correct
2 Incorrect 267 ms 604 KB Wrong Answer[5]
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 124 ms 588 KB Wrong Answer[2]
2 Halted 0 ms 0 KB -