Submission #266929

# Submission time Handle Problem Language Result Execution time Memory
266929 2020-08-15T14:23:31 Z Toirov_Sadi Library (JOI18_library) C++17
19 / 100
2000 ms 384 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);
}
# Verdict Execution time Memory Grader output
1 Correct 84 ms 256 KB # of queries: 6045
2 Correct 97 ms 256 KB # of queries: 6308
3 Correct 100 ms 256 KB # of queries: 7271
4 Correct 94 ms 384 KB # of queries: 6697
5 Correct 99 ms 256 KB # of queries: 6990
6 Correct 86 ms 256 KB # of queries: 6568
7 Correct 108 ms 384 KB # of queries: 6969
8 Correct 103 ms 256 KB # of queries: 6543
9 Correct 64 ms 372 KB # of queries: 6718
10 Correct 53 ms 256 KB # of queries: 3048
11 Correct 0 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 1 ms 256 KB # of queries: 6
15 Correct 1 ms 256 KB # of queries: 49
16 Correct 4 ms 384 KB # of queries: 175
# Verdict Execution time Memory Grader output
1 Correct 84 ms 256 KB # of queries: 6045
2 Correct 97 ms 256 KB # of queries: 6308
3 Correct 100 ms 256 KB # of queries: 7271
4 Correct 94 ms 384 KB # of queries: 6697
5 Correct 99 ms 256 KB # of queries: 6990
6 Correct 86 ms 256 KB # of queries: 6568
7 Correct 108 ms 384 KB # of queries: 6969
8 Correct 103 ms 256 KB # of queries: 6543
9 Correct 64 ms 372 KB # of queries: 6718
10 Correct 53 ms 256 KB # of queries: 3048
11 Correct 0 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 1 ms 256 KB # of queries: 6
15 Correct 1 ms 256 KB # of queries: 49
16 Correct 4 ms 384 KB # of queries: 175
17 Execution timed out 3004 ms 384 KB Time limit exceeded
18 Halted 0 ms 0 KB -