답안 #653943

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
653943 2022-10-29T00:56:24 Z baojiaopisu Art Collections (BOI22_art) C++17
컴파일 오류
0 ms 0 KB
#include<bits/stdc++.h>

using namespace std;

using ll = long long;
using ld = long double;
using ull = unsigned long long;

using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pld = pair<ld, ld>;

#define fi first
#define se second
#define pb push_back
#define pf push_front
#define mp make_pair
#define ins insert
#define btpc __builtin_popcount
#define btclz __builtin_clz

#define sz(x) (int)(x.size());
#define all(x) x.begin(), x.end()
#define debug(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int d4x[4] = {1, 0, -1, 0}; int d4y[4] = {0, 1, 0, -1};
int d8x[8] = {0, 1, 1, 1, 0, -1, -1, -1};
int d8y[8] = {1, 1, 0, -1, -1, -1, 0, 1};

template<class X, class Y>
    bool minimize(X &x, const Y &y) {
        if (x > y)
        {
            x = y;
            return true;
        }
        return false;
    }
template<class X, class Y>
    bool maximize(X &x, const Y &y) {
        if (x < y)
        {
            x = y;
            return true;
        }
        return false;
    }

const int MOD = 1e9 + 7; //998244353

template<class X, class Y>
	void add(X &x, const Y &y) {
		x = (x + y);
		if(x >= MOD) x -= MOD;
	}

template<class X, class Y> 
	void sub(X &x, const Y &y) {
		x = (x - y);
		if(x < 0) x += MOD;
	}

/* Author : Le Ngoc Bao Anh, 12A5, LQD High School for Gifted Student*/

const ll INF = 1e9;
const int N = 1e5 + 10;

int L[N], R[N];

void solve(int n) {
	vector<int> a;
	for(int i = 1; i <= n; i++) a.pb(i);
	int x = publish(a);
	int smaller = 0, larger = 0;
	for(int i = 2; i <= n; i++) {
		swap(a[0], a[i - 1]);
		int p = publish(a);
		if(p > x) {
			//i is behind 1
			int c = p - x;
			c = (c - 1) / 2;
			int pos = 1;
			while(c) pos = R[pos];
			if(R[pos]) {
				L[R[pos]] = i;
				R[i] = R[pos];
			}

			L[i] = pos;
			R[pos] = i;
		} else {
			int c = x - p;
			c = (c - 1) / 2;
			int pos = 1;
			while(c) pos = L[pos];
			if(L[pos]) {
				R[L[pos]] = i;
				L[i] = L[pos];
			}

			R[i] = pos;
			L[pos] = i;
		}

		swap(a[0], a[i - 1]);
	}

	int p = 1;
	while(L[p]) p = L[p];
	vector<int> ans;
	while(p) ans.pb(p), p = R[p];
	answer(ans);
}

Compilation message

art.cpp: In function 'void solve(int)':
art.cpp:75:10: error: 'publish' was not declared in this scope
   75 |  int x = publish(a);
      |          ^~~~~~~
art.cpp:114:2: error: 'answer' was not declared in this scope
  114 |  answer(ans);
      |  ^~~~~~
art.cpp:76:6: warning: unused variable 'smaller' [-Wunused-variable]
   76 |  int smaller = 0, larger = 0;
      |      ^~~~~~~
art.cpp:76:19: warning: unused variable 'larger' [-Wunused-variable]
   76 |  int smaller = 0, larger = 0;
      |                   ^~~~~~
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) {
      |        ~~~~~~~~~^~~~