Submission #691015

# Submission time Handle Problem Language Result Execution time Memory
691015 2023-01-30T20:51:54 Z PagodePaiva Art Collections (BOI22_art) C++17
Compilation error
0 ms 0 KB
#include<bits/stdc++.h>
#include "art.h"
#define pb push_back
#define all(v) v.begin(), v.end()

using namespace std;

int n;

vector <int> busca(vector <int> v, int k){
	int l = 0, r = v.size();

	while(l < r){
		int mid = (l+r) >> 1;
		int t = v.size();
		if(mid == t){
			l = t;
			break;
		}

		vector <int> aux;

		aux.pb(k);
		aux.pb(v[mid]);

		for(int i = 1;i <= n;i++){
			if(i == k or i == v[mid]) continue;
			aux.pb(i);
		}

		int x = publish(aux);
		aux[0] = v[mid];
		aux[1] = k;
		int y = publish(aux);

		if(x > y){
			// v[mid] > k
			r = mid;
		}

		else{
			l = mid+1;
		}
	}

	vector <int> res;

	for(int i = 0;i < l;i++){
		res.pb(v[i]);
	}

	res.pb(k);

	for(int i = l;i < t;i++){
		res.pb(v[i]);
	}

	return res;
}

void solve(int N){
	n = N;
	vector <int> v;
	v.pb(1);

	for(int i = 2;i <= n;i++){
		v = busca(v, i);
	}

	reverse(all(v));

	answer(v);

	return;
}

Compilation message

art.cpp: In function 'std::vector<int> busca(std::vector<int>, int)':
art.cpp:54:20: error: 't' was not declared in this scope
   54 |  for(int i = l;i < t;i++){
      |                    ^
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) {
      |        ~~~~~~~~~^~~~