Submission #1024592

# Submission time Handle Problem Language Result Execution time Memory
1024592 2024-07-16T08:26:54 Z Issa Digital Circuit (IOI22_circuit) C++17
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
pair<int, int> pii;

const int maxn = 1e5 + 100;

int n, d, c;
int used[maxn];
int f[maxn];

void move_inside(int i);
void move_outside(int i);
int press_button();

void add(int i){
	used[i] = 1;
	c += f[i];
	move_inside(i);
}
void del(int i){
	used[i] = 0;
	c -= f[i];
	move_outside(i);
}
void clear(){
	for(int i = 1; i <= n; i++){
		if(used[i]) del(i);
	}
}

void calc(int x, int y){
	if(x < y){
		for(int i = 0; i < n; i++){
			if(used[i]) continue;
			add(i);
			if(press_button() > y) del(i);
		}
	} else{
		for(int i = n - 1; i >= 0; i--){
			if(used[i] && press_button() > y){
				del(i);
			}
		}
		for(int i = 0; i < n; i++){
			if(used[i]) continue;
			add(i);
			if(press_button() > y) del(i);
		}
	}
}

int min_cardinality(int N){
	d = 0; n = N;
	for(int i = N - 1; i >= 0; i--){
		add(i);
		if(press_button() == 1) f[i] = 1, d++;
		else del(i);
	} clear(); c = 0;
	int ans = n, x = 0;
	for(int l = 1, r = n - 1; l <= r;){
		int mid = (l + r) >> 1;
		calc(x, mid); x = mid;
		if(!c) l = mid + 1;
		else r = mid - 1, ans = mid;
	}
	return ans;
}

Compilation message

/usr/bin/ld: /tmp/cch01q11.o: in function `main':
stub.cpp:(.text.startup+0x128): undefined reference to `init(int, int, std::vector<int, std::allocator<int> >, std::vector<int, std::allocator<int> >)'
/usr/bin/ld: stub.cpp:(.text.startup+0x169): undefined reference to `count_ways(int, int)'
/usr/bin/ld: /tmp/ccMsw0A1.o: in function `clear()':
circuit.cpp:(.text+0xbd): undefined reference to `move_outside(int)'
/usr/bin/ld: /tmp/ccMsw0A1.o: in function `calc(int, int)':
circuit.cpp:(.text+0x135): undefined reference to `move_outside(int)'
/usr/bin/ld: circuit.cpp:(.text+0x16c): undefined reference to `move_inside(int)'
/usr/bin/ld: circuit.cpp:(.text+0x171): undefined reference to `press_button()'
/usr/bin/ld: circuit.cpp:(.text+0x1f0): undefined reference to `move_inside(int)'
/usr/bin/ld: circuit.cpp:(.text+0x1f5): undefined reference to `press_button()'
/usr/bin/ld: circuit.cpp:(.text+0x213): undefined reference to `move_outside(int)'
/usr/bin/ld: circuit.cpp:(.text+0x221): undefined reference to `press_button()'
/usr/bin/ld: circuit.cpp:(.text+0x266): undefined reference to `move_outside(int)'
/usr/bin/ld: /tmp/ccMsw0A1.o: in function `min_cardinality(int)':
circuit.cpp:(.text+0x2e7): undefined reference to `move_inside(int)'
/usr/bin/ld: circuit.cpp:(.text+0x2ec): undefined reference to `press_button()'
/usr/bin/ld: circuit.cpp:(.text+0x312): undefined reference to `move_outside(int)'
/usr/bin/ld: circuit.cpp:(.text+0x36b): undefined reference to `move_outside(int)'
/usr/bin/ld: /tmp/ccMsw0A1.o: in function `add(int)':
circuit.cpp:(.text+0x26): undefined reference to `move_inside(int)'
/usr/bin/ld: /tmp/ccMsw0A1.o: in function `del(int)':
circuit.cpp:(.text+0x56): undefined reference to `move_outside(int)'
collect2: error: ld returned 1 exit status