답안 #267042

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
267042 2020-08-15T17:54:36 Z Toirov_Sadi 도서관 (JOI18_library) C++17
19 / 100
2000 ms 548 KB
#include<bits/stdc++.h>
#include "library.h"

using namespace std;

void Solve(int n){
    vector<int> q(n, 1);
    vector<int> q1(n, 0);
    unordered_set<int> p;
    for(int i = 1; i <= n; i ++) p.insert(i);
    vector<int> l, r;
    while((int)p.size() > 1){
        int x = -1;
        int y = -1;
        for(auto X: p){
            if(x != -1 && y != -1) break;
            q[X - 1] = 0;
            if(Query(q) == 1){
                if(x == -1) x = X;
                else if(y == -1) y = X;
            }
            q[X - 1] = 1;
        }
        if(!l.empty()){
            int z = x;
            q1[z - 1] = 1;
            q1[l.back() - 1] = 1;
            if(Query(q1) == 2) swap(x, y);
            q1[z - 1] = 0;
            q1[l.back() - 1] = 0;
        }
        l.push_back(x);
        r.push_back(y);
        p.erase(x);
        p.erase(y);
        q[x - 1] = 0;
        q[y - 1] = 0;
    }

    if(!p.empty()) l.push_back(*p.begin());
    vector<int> res;
    for(int i = 0; i < (int)l.size(); i ++) res.push_back(l[i]);
    for(int i = (int)r.size() - 1; i >= 0; i --) res.push_back(r[i]);
    Answer(res);
}
# 결과 실행 시간 메모리 Grader output
1 Correct 75 ms 376 KB # of queries: 6045
2 Correct 83 ms 376 KB # of queries: 6308
3 Correct 107 ms 256 KB # of queries: 7271
4 Correct 92 ms 384 KB # of queries: 6697
5 Correct 85 ms 256 KB # of queries: 6990
6 Correct 95 ms 384 KB # of queries: 6568
7 Correct 83 ms 384 KB # of queries: 6969
8 Correct 113 ms 504 KB # of queries: 6543
9 Correct 96 ms 376 KB # of queries: 6718
10 Correct 48 ms 256 KB # of queries: 3048
11 Correct 1 ms 256 KB # of queries: 0
12 Correct 0 ms 256 KB # of queries: 2
13 Correct 0 ms 256 KB # of queries: 3
14 Correct 0 ms 256 KB # of queries: 6
15 Correct 1 ms 256 KB # of queries: 49
16 Correct 4 ms 256 KB # of queries: 175
# 결과 실행 시간 메모리 Grader output
1 Correct 75 ms 376 KB # of queries: 6045
2 Correct 83 ms 376 KB # of queries: 6308
3 Correct 107 ms 256 KB # of queries: 7271
4 Correct 92 ms 384 KB # of queries: 6697
5 Correct 85 ms 256 KB # of queries: 6990
6 Correct 95 ms 384 KB # of queries: 6568
7 Correct 83 ms 384 KB # of queries: 6969
8 Correct 113 ms 504 KB # of queries: 6543
9 Correct 96 ms 376 KB # of queries: 6718
10 Correct 48 ms 256 KB # of queries: 3048
11 Correct 1 ms 256 KB # of queries: 0
12 Correct 0 ms 256 KB # of queries: 2
13 Correct 0 ms 256 KB # of queries: 3
14 Correct 0 ms 256 KB # of queries: 6
15 Correct 1 ms 256 KB # of queries: 49
16 Correct 4 ms 256 KB # of queries: 175
17 Execution timed out 3071 ms 548 KB Time limit exceeded
18 Halted 0 ms 0 KB -