Submission #714314

# Submission time Handle Problem Language Result Execution time Memory
714314 2023-03-24T08:33:00 Z vjudge1 Art Collections (BOI22_art) C++17
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
#include <art.h>

#define ll long long
#define pii pair<int, int>

using namespace std;

int n;

bool comp(int a, int b){
    vector<int> v = {a, b};
    for (int i = 1; i <= n; i++)
    {
        if(a == i || b == i) continue;
        v.emplace_back(i);
    }
    int p1 = publish(v);
    swap(v[0], v[1]);
    int p2 = publish(v);
    return p1 < p2;
}

void rec(int l, int r, vector<int>& v){
    if(l == r) return;
    int mid = (l + r) / 2;
    int p1 = l, p2 = mid + 1;
    int i = l;
    vector<int> v1, v2;
    for (int i = l; i <= mid; i++)
    {
        v1.emplace_back(v[i]);
    }
    for (int i = mid + 1; i <= r; i++)
    {
        v2.emplace_back(v[i]);
    }
    
    int i = l;
    while(p1 <= mid && p2 <= r){
        if(comp(v1[p1 - l], v2[p2 - mid - 1])){
            v[i] = v1[p1 - l];
            p1++;
        }
        else{
            v[i] = v2[p2 - mid - 1];
            p2++;
        }
        i++;
    }
    while(p1 <= mid){
        v[i++] = v1[(p1 - l)];
        p1++;
    }
    while(p2 <= r){
        v[i++] = v2[p2 - mid - 1];
        p2++;
    }
}


void solve(int N){
    n = N;
    vector<int> v(n);
    for (int i = 0; i < n; i++)
    {
        v[i] = i + 1;
    }
    rec(0, n - 1, v);

    answer(v);
}

Compilation message

art.cpp: In function 'void rec(int, int, std::vector<int>&)':
art.cpp:39:9: error: redeclaration of 'int i'
   39 |     int i = l;
      |         ^
art.cpp:28:9: note: 'int i' previously declared here
   28 |     int i = l;
      |         ^
interface.cpp: In function 'int publish(std::vector<int>)':
interface.cpp:20:17: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   20 |     if(v.size() != N) {
      |        ~~~~~~~~~^~~~
interface.cpp: In function 'void answer(std::vector<int>)':
interface.cpp:36:17: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   36 |     if(v.size() != N) {
      |        ~~~~~~~~~^~~~