Submission #679135

# Submission time Handle Problem Language Result Execution time Memory
679135 2023-01-07T14:45:17 Z Ronin13 Library (JOI18_library) C++14
0 / 100
41 ms 288 KB
#include <cstdio>
#include <vector>
#include "library.h"
#include <bits/stdc++.h>
#define pb push_back
using namespace std;

vector <int> vec;
vector <int> def;
int n;
int get(int x){
    int l = -1, r = vec.size() - 1;
    while(l + 1 < r){
        int mid = (l + r) / 2;
        vector <int> qv;
        for(int j = 0; j <= mid; j++){
            qv.pb(vec[j]);
        }
        for(int to : qv) def[to - 1] = 1;
        int u = Query(def);
        def[x - 1] = 1;
        int v = Query(def);
        if(u == v) r = mid;
        else l = mid;
        def.assign(n, 0);
    }
    return vec[r];
}

void Solve(int N)
{
	n = N;

	for(int i = 1; i <= n; i++)
        vec.pb(i), def.pb(0);;
    vector <int> ans;
    for(int i = 1; i <= n; i++){
        vector <int> qv;
        for(int j = 0; j < i - 1; j++) qv.pb(vec[j]);
        for(int j = i; j < vec.size(); j++) qv.pb(vec[j]);
        for(int to : qv)
            def[to - 1] = 1;
        int l = Query(def);
        def.assign(n, 0);
        if(l == 1){
            ans.pb(i);
            break;
        }
    }
    //cout << ans.back();
    for(int j = 1; j < n; j++){
        for(int x = 0; x < vec.size(); x++){
            if(vec[x] == ans.back()){
                int pos = x;
                while(pos < vec.size() - 1) swap(vec[pos], vec[pos + 1]), pos++;
                vec.pop_back();
                break;
            }
        }
        ans.pb(get(ans.back()));
    }
    Answer(ans);
}

Compilation message

library.cpp: In function 'void Solve(int)':
library.cpp:40:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   40 |         for(int j = i; j < vec.size(); j++) qv.pb(vec[j]);
      |                        ~~^~~~~~~~~~~~
library.cpp:52:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   52 |         for(int x = 0; x < vec.size(); x++){
      |                        ~~^~~~~~~~~~~~
library.cpp:55:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   55 |                 while(pos < vec.size() - 1) swap(vec[pos], vec[pos + 1]), pos++;
      |                       ~~~~^~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 37 ms 288 KB # of queries: 2375
2 Correct 35 ms 208 KB # of queries: 2409
3 Correct 41 ms 208 KB # of queries: 2648
4 Correct 25 ms 208 KB # of queries: 2595
5 Correct 36 ms 208 KB # of queries: 2508
6 Correct 33 ms 208 KB # of queries: 2551
7 Correct 39 ms 208 KB # of queries: 2544
8 Correct 34 ms 208 KB # of queries: 2420
9 Correct 37 ms 208 KB # of queries: 2546
10 Correct 19 ms 208 KB # of queries: 1474
11 Runtime error 1 ms 208 KB Execution killed with signal 13
12 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 37 ms 288 KB # of queries: 2375
2 Correct 35 ms 208 KB # of queries: 2409
3 Correct 41 ms 208 KB # of queries: 2648
4 Correct 25 ms 208 KB # of queries: 2595
5 Correct 36 ms 208 KB # of queries: 2508
6 Correct 33 ms 208 KB # of queries: 2551
7 Correct 39 ms 208 KB # of queries: 2544
8 Correct 34 ms 208 KB # of queries: 2420
9 Correct 37 ms 208 KB # of queries: 2546
10 Correct 19 ms 208 KB # of queries: 1474
11 Runtime error 1 ms 208 KB Execution killed with signal 13
12 Halted 0 ms 0 KB -