답안 #409435

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
409435 2021-05-20T17:52:34 Z Alma 도서관 (JOI18_library) C++17
0 / 100
186 ms 272 KB
#include <bits/stdc++.h>
#include "library.h"
using namespace std;

void Solve(int N) {
    vector<int> res;
    if (N == 1) {
        res = {1};
        Answer(res);
    }
    else if (N == 2){
        res = {1, 2};
        Answer(res);
    }
    vector<int> M(N, 1);
    int extremo = -1;
    for (int i = 0; i < N; i++) {
        M[i] = 0;
        if (Query(M) == 1) {
            extremo = i;
            break;
        }
        M[i] = 1;
    }
    if (extremo == -1) extremo = N-1;
    
    res.push_back(extremo+1);
    M.assign(N, 0);
    vector<bool> puesto(N, false);
    puesto[extremo] = true;
    int libro_izq = extremo;

    while ((int)res.size() < N) {
        for (int i = 0; i < N; i++) {
            if (puesto[i]) continue;
            M[libro_izq] = 1; M[i] = 1;
            if (Query(M) == 1) {
                res.push_back(i+1);
                puesto[i] = true;
                libro_izq = i;
                break;
            }
            M[libro_izq] = 0; M[i] = 0;
        }
    }
    Answer(res);
}
# 결과 실행 시간 메모리 Grader output
1 Correct 174 ms 200 KB # of queries: 9387
2 Correct 132 ms 200 KB # of queries: 9921
3 Correct 109 ms 272 KB # of queries: 10593
4 Correct 129 ms 268 KB # of queries: 9984
5 Correct 105 ms 268 KB # of queries: 10491
6 Correct 125 ms 200 KB # of queries: 9332
7 Correct 156 ms 200 KB # of queries: 10200
8 Correct 152 ms 200 KB # of queries: 9064
9 Correct 186 ms 272 KB # of queries: 10493
10 Correct 64 ms 272 KB # of queries: 4192
11 Runtime error 1 ms 200 KB Execution killed with signal 13
12 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 174 ms 200 KB # of queries: 9387
2 Correct 132 ms 200 KB # of queries: 9921
3 Correct 109 ms 272 KB # of queries: 10593
4 Correct 129 ms 268 KB # of queries: 9984
5 Correct 105 ms 268 KB # of queries: 10491
6 Correct 125 ms 200 KB # of queries: 9332
7 Correct 156 ms 200 KB # of queries: 10200
8 Correct 152 ms 200 KB # of queries: 9064
9 Correct 186 ms 272 KB # of queries: 10493
10 Correct 64 ms 272 KB # of queries: 4192
11 Runtime error 1 ms 200 KB Execution killed with signal 13
12 Halted 0 ms 0 KB -