Submission #1080148

# Submission time Handle Problem Language Result Execution time Memory
1080148 2024-08-29T07:27:24 Z adaawf Library (JOI18_library) C++17
0 / 100
26 ms 344 KB
#include <iostream>
#include <vector>
#include "library.h"
using namespace std;
int dd[1005];
/*int Query(vector<int> v) {
    for (int w : v) cout << w << " ";
    cout << endl;
    int x;
    cin >> x;
    return x;
}
void Answer(vector<int> v) {
    for (int w : v) cout << w << " ";
    cout << endl;
}*/
void Solve(int n) {
    for (int i = 0; i < n; i++) dd[i] = 0;
    vector<int> res;
    for (int i = 0; i < n; i++) {
        vector<int> vv;
        for (int j = 0; j < n; j++) {
            if (i == j) vv.push_back(0);
            else vv.push_back(1);
        }
        if (Query(vv) == 1) {
            res.push_back(i);
            break;
        }
    }
    for (int i = 0; i < n; i++) {
        if (i == res.back()) continue;
        vector<int> vv;
        for (int j = 0; j < n; j++) {
            if (j == i || j == res.back()) vv.push_back(1);
            else vv.push_back(0);
        }
        if (Query(vv) == 1) {
            res.push_back(i);
            break;
        }
    }
    dd[res[0]] = dd[res[1]] = 1;
    for (int i = 2; i < n; i++) {
        vector<int> v;
        for (int j = 0; j < n; j++) {
            if (dd[j] == 0) {
                v.push_back(j);
            }
        }
        int l = 0, r = v.size() - 2, g = v.size() - 1;
        while (l <= r) {
            int mid = (l + r) / 2;
            vector<int> vv(n);
            for (int j = 0; j <= mid; j++) vv[v[j]] = 1;
            for (int j = 0; j < res.size(); j++) vv[res[j]] = 1;
            int h = Query(vv);
            vv[res.back()] = 0;
            int k = Query(vv);
            if (h != k) {
                g = mid;
                r = mid - 1;
            }
            else l = mid + 1;
        }
        res.push_back(v[g]);
        dd[v[g]] = 1;
    }
    for (int &w : res) w++;
    Answer(res);
}
/*int main() {
    Solve(5);
}*/

Compilation message

library.cpp: In function 'void Solve(int)':
library.cpp:56:31: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   56 |             for (int j = 0; j < res.size(); j++) vv[res[j]] = 1;
      |                             ~~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 20 ms 344 KB # of queries: 2367
2 Correct 23 ms 344 KB # of queries: 2570
3 Correct 16 ms 344 KB # of queries: 2668
4 Correct 24 ms 344 KB # of queries: 2740
5 Correct 26 ms 344 KB # of queries: 2600
6 Correct 25 ms 344 KB # of queries: 2726
7 Correct 22 ms 344 KB # of queries: 2708
8 Correct 24 ms 344 KB # of queries: 2575
9 Correct 25 ms 344 KB # of queries: 2662
10 Correct 12 ms 344 KB # of queries: 1534
11 Runtime error 1 ms 344 KB Execution killed with signal 11
12 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 20 ms 344 KB # of queries: 2367
2 Correct 23 ms 344 KB # of queries: 2570
3 Correct 16 ms 344 KB # of queries: 2668
4 Correct 24 ms 344 KB # of queries: 2740
5 Correct 26 ms 344 KB # of queries: 2600
6 Correct 25 ms 344 KB # of queries: 2726
7 Correct 22 ms 344 KB # of queries: 2708
8 Correct 24 ms 344 KB # of queries: 2575
9 Correct 25 ms 344 KB # of queries: 2662
10 Correct 12 ms 344 KB # of queries: 1534
11 Runtime error 1 ms 344 KB Execution killed with signal 11
12 Halted 0 ms 0 KB -