Submission #266893

# Submission time Handle Problem Language Result Execution time Memory
266893 2020-08-15T14:02:22 Z Toirov_Sadi Library (JOI18_library) C++17
0 / 100
89 ms 384 KB
#include<bits/stdc++.h>
#include "library.h"

using namespace std;

void Solve(int N){
    set<int> p;
    vector<int> q(N, 1);
    vector<int> q1(N, 0);
    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()){
            q1[x - 1] = 1;
            q1[l.back() - 1] = 1;
            if(Query(q1) == 2){
                swap(x, y);
            }
        }
        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);
}
# Verdict Execution time Memory Grader output
1 Incorrect 89 ms 384 KB Wrong Answer [8]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 89 ms 384 KB Wrong Answer [8]
2 Halted 0 ms 0 KB -