社区讨论

超级无敌生气暴怒😡调了inf小时

P12506 「ROI 2025 Day2」沼泽里的青蛙参与者 6已保存回复 6

讨论操作

快速查看讨论及其快照的属性,并进行相关操作。

当前回复
6 条
当前快照
1 份
快照标识符
@mhj0mvgg
此快照首次捕获于
2025/11/03 18:47
4 个月前
此快照最后确认于
2025/11/03 18:47
4 个月前
查看原帖
sub6 的包全都WA了,代码中有一些细节还是错的,是为了方便调试sub 6。已经调了两天都没发现有啥问题。
CPP
#include <bits/stdc++.h>
#define ll long long
#define dd double
using namespace std;
template <typename T> inline void D(T &x)
{
	x = 0; bool f = 0; char ch = getchar();
	while('0' > ch || ch > '9') { if(ch == '-') f = !f; ch = getchar(); }
	while('0' <= ch && ch <= '9') { x = (x << 1) + (x << 3) + (ch ^ 48); ch = getchar(); }
	x = f ? -x : x; return;
}
template <typename T> inline void P(T x)
{
	if(x < 0) putchar('-'), x = -x;
	if(x > 9) P(x / 10);
	putchar(x % 10 + '0'); return;
}
const int N = 1e5 + 10;
struct node {int x, y;};
int n, r, blk, cnt, tot;
int x[N], y[N], xx[N], yy[N];
ll bel[N];
ll ch(int x, int y, int z) { return 1ll * (x - 1) * z + y; }
unordered_map<ll, int> num, tg, id;
vector <int> e[N];
int vis[N], stac[N], lc, flag, ans[N];
int ld;
ll dl[N];
vector <int> g[N];
void dfs(int u, int c)
{
	if (vis[u])
	{
		if (vis[u] != c) flag = 1;
		return;
	}
	vis[u] = c;
	stac[++ lc] = u;
	if (tg[bel[u]]) flag = 1;
	for (int v : e[u])
	{
		dfs(v, 3 - c);
	}
}
int calc(int u, int v)
{
	int cx = abs(x[u] - x[v]), cy = abs(y[u] - y[v]);
	if (1ll * cx * cx + 1ll * cy * cy <= 1ll * r * r) return 1;
	return 0;
}
void work(int p)
{
	int pp = 2;
	//if (r <= 2) pp = 10;
	for (int sx = max(1, xx[p] - pp); sx <= min(xx[p] + pp, cnt); sx ++)
	{
		for (int sy = max(1, yy[p] - pp); sy <= min(yy[p] + pp, cnt); sy ++)
		{
			ll bb = ch(sx, sy, cnt);
			if (!id[bb]) continue;
			for (int v : g[id[bb]])
			{
				if (v != p && calc(v, p))
				{
					e[p].push_back(v), e[v].push_back(p);
				}
			}
				
		}
	}
}
void solve()
{
	cin >> n >> r;
	for (int i = 1; i <= n; i ++)
	{
		cin >> x[i] >> y[i];
		x[i] ++, y[i] ++;
	}
	
	
	blk = (r + 1) / 2;
	cnt = 1e9 / blk + (1000000000 % blk > 0);
	for (int i = 1; i <= n; i ++)
	{
		xx[i] = (x[i] - 1) / blk + 1, yy[i] = (y[i] - 1) / blk + 1;
		int res = ch(xx[i], yy[i], cnt);
		bel[i] = res;
		num[bel[i]] ++;
		if (num[bel[i]] >= 3) tg[bel[i]] = 1;
		dl[++ ld] = bel[i];
	}
	sort(dl + 1, dl + 1 + ld);
	ld = unique(dl + 1, dl + 1 + ld) - dl - 1;
	for (int i = 1; i <= ld; i ++) id[dl[i]] = ++ tot;
	for (int i = 1; i <= n; i ++) g[id[bel[i]]].push_back(i);
	
	for (int i = 1; i <= n; i ++)
	{
		if (tg[bel[i]] == 0)
			work(i);
	}
	
	for (int i = 1; i <= n; i ++)
	{
		lc = 0; flag = 0;
		dfs(i, 1);
		if (flag)
			for (int j = 1; j <= lc; j ++) ans[stac[j]] = 1;
	}
	for (int i = 1; i <= n; i ++)
	{
		if (tg[bel[i]] || ans[i]) cout << '1';
		else cout << '0';
	}
	cout << '\n';
}
signed main()
{
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	//freopen(".in", "r", stdin); freopen(".out", "w", stdout);
	int T; T = 1;
	while (T --) solve();
	return 0;
}

回复

6 条回复,欢迎继续交流。

正在加载回复...