Submission #570342

# Submission time Handle Problem Language Result Execution time Memory
570342 2022-05-29T09:00:10 Z Spade1 Library (JOI18_library) C++14
0 / 100
1 ms 336 KB
#include<bits/stdc++.h>
#include "library.h"
#define pii pair<int, int>
#define pll pair<long long, long long>
#define ll long long
#define ld long double
#define st first
#define nd second
#define pb push_back
#define INF INT_MAX
using namespace std;

bool mark[1010];

void Solve(int N) {
    int l = 2, r = N;
    vector<int> ans;
    ans.pb(1);
    vector<int> rmn;
    for (int i = 2; i <= N; ++i) rmn.pb(i);

    while (true) {
        int l = 0, r = rmn.size();
        while (l < r) {
            vector<int> tst(N, 0);
            int mid = (l+r+1)/2;
            for (int i = 0; i <= mid; ++i) {
                tst[rmn[i]-1] = 1;
            }
            int tmp = Query(tst);
            tst[ans.back()-1] = 1;
            if (Query(tst) > tmp) r = mid-1;
            else l = mid;
        }
        if (l == rmn.size()) break;
        else {
            ans.pb(rmn[l]);
            rmn.erase(rmn.begin()+l);
        }
    }

    reverse(ans.begin(), ans.end());

    while (true) {
        int l = 0, r = rmn.size();
        while (l < r) {
            vector<int> tst(N, 0);
            int mid = (l+r+1)/2;
            for (int i = 0; i <= mid; ++i) {
                tst[rmn[i]-1] = 1;
            }
            int tmp = Query(tst);
            tst[ans.back()-1] = 1;
            if (Query(tst) > tmp) r = mid-1;
            else l = mid;
        }
        if (l == rmn.size()) break;
        else {
            ans.pb(rmn[l]);
            rmn.erase(rmn.begin()+l);
        }
    }

    Answer(ans);
}

Compilation message

library.cpp: In function 'void Solve(int)':
library.cpp:35:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   35 |         if (l == rmn.size()) break;
      |             ~~^~~~~~~~~~~~~
library.cpp:57:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   57 |         if (l == rmn.size()) break;
      |             ~~^~~~~~~~~~~~~
library.cpp:16:9: warning: unused variable 'l' [-Wunused-variable]
   16 |     int l = 2, r = N;
      |         ^
library.cpp:16:16: warning: unused variable 'r' [-Wunused-variable]
   16 |     int l = 2, r = N;
      |                ^
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 336 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 336 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -