답안 #679139

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
679139 2023-01-07T14:49:31 Z Ronin13 도서관 (JOI18_library) C++14
0 / 100
62 ms 296 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){
        def.assign(n, 0);
        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;

    }
    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:41:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   41 |         for(int j = i; j < vec.size(); j++) qv.pb(vec[j]);
      |                        ~~^~~~~~~~~~~~
library.cpp:53:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   53 |         for(int x = 0; x < vec.size(); x++){
      |                        ~~^~~~~~~~~~~~
library.cpp:56:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   56 |                 while(pos < vec.size() - 1) swap(vec[pos], vec[pos + 1]), pos++;
      |                       ~~~~^~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 24 ms 208 KB # of queries: 2375
2 Correct 46 ms 208 KB # of queries: 2409
3 Correct 51 ms 208 KB # of queries: 2648
4 Correct 55 ms 208 KB # of queries: 2595
5 Correct 32 ms 208 KB # of queries: 2508
6 Correct 38 ms 208 KB # of queries: 2551
7 Correct 62 ms 208 KB # of queries: 2544
8 Correct 44 ms 208 KB # of queries: 2420
9 Correct 32 ms 208 KB # of queries: 2546
10 Correct 22 ms 208 KB # of queries: 1474
11 Runtime error 1 ms 296 KB Execution killed with signal 13
12 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 24 ms 208 KB # of queries: 2375
2 Correct 46 ms 208 KB # of queries: 2409
3 Correct 51 ms 208 KB # of queries: 2648
4 Correct 55 ms 208 KB # of queries: 2595
5 Correct 32 ms 208 KB # of queries: 2508
6 Correct 38 ms 208 KB # of queries: 2551
7 Correct 62 ms 208 KB # of queries: 2544
8 Correct 44 ms 208 KB # of queries: 2420
9 Correct 32 ms 208 KB # of queries: 2546
10 Correct 22 ms 208 KB # of queries: 1474
11 Runtime error 1 ms 296 KB Execution killed with signal 13
12 Halted 0 ms 0 KB -