Submission #732128

# Submission time Handle Problem Language Result Execution time Memory
732128 2023-04-28T14:02:52 Z nguyentunglam Library (JOI18_library) C++17
0 / 100
3 ms 208 KB
#include<bits/stdc++.h>
#include <cstdio>
#include <vector>
#include "library.h"
using namespace std;
const int N = 1e5 + 10;
bool taken[N];
int n;
int query(vector<int> v) {
    vector<int> ask(n);
    for(int &j : v) ask[j - 1] = 1;
    return Query(ask);
}

vector<int> operator + (vector<int> a, vector<int> b) {
    vector<int> c = a;
    for(int &j : b) c.push_back(j);
    return c;
}

int Find(vector<int> lst, int x, int y) {
    if (lst.size() == 1) return lst[0];
    vector<int> Left, Right;
    for(int i = 0; i < lst.size(); i++) {
        if (i < lst.size() / 2) Left.push_back(lst[i]);
        else Right.push_back(lst[i]);
    }
    vector<int> v1 = {x, y}, v2 = {y};
    if (query(Left + v1) + 1 == query(Left + v2)) return Find(Left, x, y);
    return Find(Right, x, y);
}

void Solve(int N)
{
    n = N;
    int l = 1, r = n;
    for(int i = 1; i <= n; i++) if (i != l && query({l, i}) == 1) {
        r = i;
        break;
    }

    taken[l] = taken[r] = 1;
    vector<int> init;
    for(int i = 1; i <= n; i++) if (!taken[i]) init.push_back(i);
    int tmp = Find(init, l, r);
    taken[tmp] = 1;
    if (query({tmp, r}) == 1) swap(l, r);
    int x, y;
    vector<int> f, g, h = {tmp, l, r};

//    x = tmp; y = l;
//    while (1) {
//        vector<int> ask;
//        for(int i = 1; i <= n; i++) if (!taken[i]) ask.push_back(i);
//        if (ask.empty()) break;
//        int idx = Find(ask, x, y);
//        if (query({idx, x, y}) != 1) break;
//        y = x;
//        x = idx;
//        taken[idx] = 1;
//        f.push_back(idx);
//    }
//
//    x = r; y = l;
//    while (1) {
//        vector<int> ask;
//        for(int i = 1; i <= n; i++) if (!taken[i]) ask.push_back(i);
//        if (ask.empty()) break;
//        int idx = Find(ask, x, y);
//        cout << idx << endl;
//        if (query({idx, x, y}) != 1) break;
//        y = x;
//        x = idx;
//        taken[idx] = 1;
//        g.push_back(idx);
//    }
//
//    reverse(f.begin(), f.end());
//    Answer(f + h + g);
}

Compilation message

library.cpp: In function 'int Find(std::vector<int>, int, int)':
library.cpp:24:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   24 |     for(int i = 0; i < lst.size(); i++) {
      |                    ~~^~~~~~~~~~~~
library.cpp:25:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   25 |         if (i < lst.size() / 2) Left.push_back(lst[i]);
      |             ~~^~~~~~~~~~~~~~~~
library.cpp: In function 'void Solve(int)':
library.cpp:48:9: warning: unused variable 'x' [-Wunused-variable]
   48 |     int x, y;
      |         ^
library.cpp:48:12: warning: unused variable 'y' [-Wunused-variable]
   48 |     int x, y;
      |            ^
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 208 KB Wrong Answer [7]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 208 KB Wrong Answer [7]
2 Halted 0 ms 0 KB -