Submission #962141

# Submission time Handle Problem Language Result Execution time Memory
962141 2024-04-13T07:36:41 Z lotusblume Art Collections (BOI22_art) C++17
Compilation error
0 ms 0 KB
#include <iostream>
#include <vector>

#include "art.h"

void solve(int n)
	std::vector<int> p(n);

	for (int i = 0; i < n; ++i) {
		p[i] = i + 1;
	}

	int orig = publish(p);

	std::vector<int> ans(n, 0);

	for (int i = 0; i < n - 1; ++i) {
		for (int j = 0; j < i; ++j) {
			p[j] = j + 1;
		}
		for (int j = i; j < n - 1; ++j) {
			p[j] = j + 2;
		}
		p[n - 1] = i + 1;
		int dif = orig - publish(p);
		int x = ((n - i - 1) + dif) / 2;
		for (int j = 0; j < n; ++j) {
			if (ans[j] == 0) {
				if (x == 0) {
					ans[j] = i + 1;
					break;
				}
				else {
					--x;
				}
			}
		}
	}

	for (int j = 0; j < n; ++j) {
		if (ans[j] == 0) {
			ans[j] = n;
			break;
		}
	}

	answer(ans);
}

Compilation message

art.cpp:7:2: error: expected initializer before 'std'
    7 |  std::vector<int> p(n);
      |  ^~~
art.cpp:9:2: error: expected unqualified-id before 'for'
    9 |  for (int i = 0; i < n; ++i) {
      |  ^~~
art.cpp:9:18: error: 'i' does not name a type
    9 |  for (int i = 0; i < n; ++i) {
      |                  ^
art.cpp:9:25: error: expected unqualified-id before '++' token
    9 |  for (int i = 0; i < n; ++i) {
      |                         ^~
art.cpp:13:21: error: 'p' was not declared in this scope
   13 |  int orig = publish(p);
      |                     ^
art.cpp:15:23: error: 'n' was not declared in this scope
   15 |  std::vector<int> ans(n, 0);
      |                       ^
art.cpp:17:2: error: expected unqualified-id before 'for'
   17 |  for (int i = 0; i < n - 1; ++i) {
      |  ^~~
art.cpp:17:18: error: 'i' does not name a type
   17 |  for (int i = 0; i < n - 1; ++i) {
      |                  ^
art.cpp:17:29: error: expected unqualified-id before '++' token
   17 |  for (int i = 0; i < n - 1; ++i) {
      |                             ^~
art.cpp:40:2: error: expected unqualified-id before 'for'
   40 |  for (int j = 0; j < n; ++j) {
      |  ^~~
art.cpp:40:18: error: 'j' does not name a type
   40 |  for (int j = 0; j < n; ++j) {
      |                  ^
art.cpp:40:25: error: expected unqualified-id before '++' token
   40 |  for (int j = 0; j < n; ++j) {
      |                         ^~
art.cpp:47:8: error: expected constructor, destructor, or type conversion before '(' token
   47 |  answer(ans);
      |        ^
art.cpp:48:1: error: expected declaration before '}' token
   48 | }
      | ^
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) {
      |        ~~~~~~~~~^~~~