Submission #398685

# Submission time Handle Problem Language Result Execution time Memory
398685 2021-05-04T17:43:39 Z galca The Collection Game (BOI21_swaps) C++14
Compilation error
0 ms 0 KB
#include <vector>
using namespace std;

void solve(int 𝑁, int 𝑉 ) {
   vector<int> res(N);
   for (int i=0; i<N; i++) {
	  res[i] = i;
   }  

   for (int k = 2; k <= N; k *= 2) {
        for (int j = k/2; j > 0; j /= 2) { 
            for (i = 0; i < N; i++) {
                int ip = i ^ j; 
                if (ip > i) {
                    if (i ^ k == 0) schedule(ip, i);
					else schedule(i, ip);
				}
            }

			vector<int> v = visit();

			for (i = 0; i < N/2; i++) {
			  int ip = i ^ j; 
              if (ip > i) {
			     if (v[i]) {
				   int tmp = res[i];
				   res[i] = res[ip];
				   res[ip] = tmp; 
				 }
              }
			}
       }
	}
	answer(res);
}

Compilation message

swaps.cpp: In function 'void solve(int, int)':
swaps.cpp:5:20: error: 'N' was not declared in this scope
    5 |    vector<int> res(N);
      |                    ^
swaps.cpp:12:18: error: 'i' was not declared in this scope
   12 |             for (i = 0; i < N; i++) {
      |                  ^
swaps.cpp:15:37: error: 'schedule' was not declared in this scope
   15 |                     if (i ^ k == 0) schedule(ip, i);
      |                                     ^~~~~~~~
swaps.cpp:16:11: error: 'schedule' was not declared in this scope
   16 |      else schedule(i, ip);
      |           ^~~~~~~~
swaps.cpp:20:20: error: 'visit' was not declared in this scope
   20 |    vector<int> v = visit();
      |                    ^~~~~
swaps.cpp:20:20: note: 'std::visit' is only available from C++17 onwards
swaps.cpp:22:9: error: 'i' was not declared in this scope
   22 |    for (i = 0; i < N/2; i++) {
      |         ^
swaps.cpp:34:2: error: 'answer' was not declared in this scope
   34 |  answer(res);
      |  ^~~~~~