Submission #1295069

#TimeUsernameProblemLanguageResultExecution timeMemory
1295069julia_08Counting Mushrooms (IOI20_mushrooms)C++20
Compilation error
0 ms0 KiB
#include <bits/stdc++.h>
#include "mushrooms.h"

using namespace std;

int get_ans(int sz, int ans, int x){
	if(x == 0) return sz / 2 - (ans + 1) / 2;
	return (ans + 1) / 2;
}

int count_mushrooms(int n){

	int x = 0;

	vector<int> pos[2];

	int k = 80;

	pos[x].push_back(0);

	int tot = 1;

	for(int i=1; i<n; i++){

		vector<int> ask;

		int sz = (int) pos[x].size();

		for(int j=i; j<min(i + sz, n); j++){
			ask.push_back(pos[x][j - i]);
			ask.push_back(j);
		}

		i = min(i + sz, n) - 1;

		int cur = use_machine(ask);

		tot += get_ans((int) ask.size(), cur, x);

		if(cur % 2 == 1){
			pos[1 - x].push_back(i);
		} else pos[x].push_back(i);

		if((int) pos[1 - x].size() > (int) pos[x].size()) x = 1 - x;

		last = i;

	}

	return tot;

}

Compilation message (stderr)

mushrooms.cpp: In function 'int count_mushrooms(int)':
mushrooms.cpp:46:17: error: 'last' was not declared in this scope; did you mean 'std::chrono::last'?
   46 |                 last = i;
      |                 ^~~~
      |                 std::chrono::last
In file included from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:172,
                 from mushrooms.cpp:1:
/usr/include/c++/13/chrono:502:32: note: 'std::chrono::last' declared here
  502 |     inline constexpr last_spec last{};
      |                                ^~~~