Submission #1359078

#TimeUsernameProblemLanguageResultExecution timeMemory
1359078whallyCoreputer (IOI23_coreputer)C++20
Compilation error
0 ms0 KiB
#include <bits/stdc++.h>
#include "coreputer.h"
using namespace std;

std::vector<int> malfunctioning_cores(int N)
{
	if (N == 2){
		int res = run_diagnostic({0});
		if (res == 0) return {1,1};
		else if (res == 1) return {1,0};
		else return {0,1};
	}
	int l = 0, r = N-1, ml = -1;
	while (l <= r){
		int mid = (l+r)/2;
		vector<int> now;
		for (int i = 0; i <= mid; i++) now.push_back(i);
		int res = run_diagnostic(now);
		if (res == 0){
			ml = mid;
			break;
		}
		if (res == -1) l = mid+1;
		else r = mid-1;
	}

	vector<int> col, ans;
	set<int> st;

	for (int i = 0; i < N; i++) ans.push_back(i);
	for (int i = 0; i <= ml; i++) st.insert(i);

	auto it = st.begin();
	while (it != st.end()){
		int er = *it;
		it = st.erase(it);
		vector<int> con;
		for (int x : st) con.push_back(x);
		int res = run_diagnostic(con);
		if (res != 0) st.insert(er); 
	}

	for (int x : st) col.push_back(x);
	st.clear();

	for (int i = ml+1; i < N; i++) st.insert(i);

	auto it = st.begin();
	while (it != st.end()){
		int er = *it;
		it = st.erase(it);
		vector<int> con;
		for (int x : st) con.push_back(x);
		int res = run_diagnostic(con);
		if (res != 0) st.insert(er); 
	}

	for (int x : st) col.push_back(x);
	st.clear();

	for (int x : col) ans[x] = 1;

	return ans;
}

Compilation message (stderr)

coreputer.cpp: In function 'std::vector<int> malfunctioning_cores(int)':
coreputer.cpp:48:14: error: conflicting declaration 'auto it'
   48 |         auto it = st.begin();
      |              ^~
coreputer.cpp:33:14: note: previous declaration as 'std::_Rb_tree_const_iterator<int> it'
   33 |         auto it = st.begin();
      |              ^~