Submission #725377

# Submission time Handle Problem Language Result Execution time Memory
725377 2023-04-17T11:01:23 Z SanguineChameleon Game (APIO22_game) C++17
Compilation error
0 ms 0 KB
#include "game.h"
#include <bits/stdc++.h>
using namespace std;
 
const int maxN = 3e5 + 20;
int block;
int max_in[maxN];
int min_out[maxN];
vector<int> adj1[maxN];
vector<int> adj2[maxN];
bool done = false;
int n, k;
 
void init(int _n, int _k) {
	n = _n;
	k = _k;
	block = 1;
	for (int i = 0; i < k; i++) {
		max_in[i] = i - 1;
		min_out[i] = i;
	}
	for (int i = k; i < n; i++) {
		max_in[i] = -1;
		min_out[i] = k;
	}
}

void update_in(int u, int val);
void update_out(int u, int val);

void update_in(int u, int val) {
	if (done) {
		return;
	}
	if (val <= max_in[u]) {
		return;
	}
	bool diff = (max_in[u] / block) < (val / block);
	bool same = (max_in[u] / block) == (min_out[u] / block);
	max_in[u] = val;
	if (max_in[u] >= min_out[u]) {
		done = true;
		return;
	}
	if (update) {
		for (auto v: adj1[u]) {
			update_in(v, max_in[u]);
		}
	}
}
 
void update_out(int u, int val) {
	if (done) {
		return;
	}
	if (val >= min_out[u]) {
		return;
	}
	bool update = ((min_out[u] / block) > (val / block) || (max_in[u] / block) == (min_out[u] / block));
	min_out[u] = val;
	if (max_in[u] >= min_out[u]) {
		done = true;
		return;
	}
	if (update) {
		for (auto v: adj2[u]) {
			update_out(v, min_out[u]);
		}
	}
}
 
int add_teleporter(int u, int v) {
	update_in(v, max(max_in[u], (u < k ? u : -1)));
	update_out(u, min_out[v]);
	adj1[u].push_back(v);
	adj2[v].push_back(u);
	return done;
}

Compilation message

game.cpp: In function 'void update_in(int, int)':
game.cpp:45:6: error: 'update' was not declared in this scope; did you mean 'update_in'?
   45 |  if (update) {
      |      ^~~~~~
      |      update_in
game.cpp:38:7: warning: unused variable 'diff' [-Wunused-variable]
   38 |  bool diff = (max_in[u] / block) < (val / block);
      |       ^~~~
game.cpp:39:7: warning: unused variable 'same' [-Wunused-variable]
   39 |  bool same = (max_in[u] / block) == (min_out[u] / block);
      |       ^~~~