跳到正文

生活·游记

My Virtual NOI in 2025

Redshift_Shine约 14 分钟
原文
文章信息与版本

文章信息

发布
2025年7月13日
收录
2025年12月12日
更新
2026年8月22日
篇幅
约 14 分钟

版本

  1. v1当前

Day 0 / Introduction

很久没在洛谷上写日记了。突然发现今天的犇犇包含“宜参加 NOI2025”,向同学询问题目才发现今天只是笔试,于是约了几个同学明天去 qoj(可能吧)上进行 duel(也就是 vp)。

简单说一下个人情况。本人不久前考完中考,目前每天在家打游戏和打比赛,等待命运降临。因为中考备战以及太菜导致无法参加 NOI。

目标是拿下 D1T1 并在后面的题目里面多拼暴力分。

Day 1

因为实在没人 duel 而且 qoj 上没题就改成了多人合作,所以比较摆。

大概用了半个小时完成 T1 实现:

C++
// #define Redshift_Debug
#ifdef Redshift_Debug
#define debug(...) fprintf(stderr, __VA_ARGS__)
#include <chrono>
#else
#define debug(...)
#endif
#include <cstdio>
#include <cstring>
#include <iostream>
#include <queue>
#include <vector>
using namespace std;
const int N = 3e5 + 10;
int c, n, m, k;
using ll = long long;
ll v[N], w[N], td[N];
vector<ll> dis[N];
vector<bool> vis[N];
const ll linf = 0x3f3f3f3f3f3f3f3f;
struct st
{
	int x, lyr;
	ll v;
	bool operator<(const st &tx) const
	{
		return v > tx.v;
	}
	st(int _x, int _lyr, ll _v) : x(_x), lyr(_lyr), v(_v)
	{
	}
};
priority_queue<st> q;
vector<vector<st>> road[N];
ll calc(int l, int r)
{
	if (r > l)
		return v[r] - v[l];
	else
		return w[l] - w[r];
}
void run()
{
	cin.tie(0);
	cout.tie(0);
	ios::sync_with_stdio(0);
	cin >> c >> n >> m >> k;
	memset(td, 0x3f, n << 3);
	for (int i = 0; i < k - 1; i++)
	{
		cin >> v[i];
	}
	for (int i = 1; i < k; i++)
	{
		cin >> w[i];
	}
	for (int i = 0, d, tx, ty, trd; i < n; i++)
	{
		cin >> d;
		trd = 0;
		dis[i].assign(d, linf);
		road[i].resize(d);
		vis[i].resize(d);
		for (auto &j : road[i])
		{
			cin >> tx >> ty;
			tx--;
			j.emplace_back(tx, trd, ty);
			if (trd)
				j.emplace_back(i, trd - 1, w[trd]);
			if (trd != d - 1)
				j.emplace_back(i, trd + 1, v[trd]);
			trd++;
		}
	}
	for (int i = 1; i < k; i++)
		v[i] += v[i - 1], w[i] += w[i - 1];
	dis[0][0] = td[0] = 0;
	q.emplace(0, 0, 0);
	while (q.size())
	{
		// cerr << "ok\n";
		st tmp = q.top(), buf(0, 0, 0);
		q.pop();
		if (vis[tmp.x][tmp.lyr])
			continue;
		vis[tmp.x][tmp.lyr] = true;
		for (auto &i : road[tmp.x][tmp.lyr])
		{
			buf = i;
			buf.v += tmp.v;
			td[buf.x] = min(td[buf.x], buf.v);
			if (!road[buf.x].size())
				continue;
			if (buf.lyr >= road[buf.x].size())
			{
				buf.v += calc(buf.lyr, road[buf.x].size() - 1);
				buf.lyr = road[buf.x].size() - 1;
			}
			if (vis[buf.x][buf.lyr] or dis[buf.x][buf.lyr] <= tmp.v)
				continue;
			dis[buf.x][buf.lyr] = buf.v;
			q.emplace(buf);
		}
	}
	for (int i = 0; i < n; i++)
	{
		cout << (td[i] == linf ? -1 : td[i]) << " \n"[i == n - 1];
	}
}
int main()
{
#ifdef Redshift_Debug
	auto st = chrono::high_resolution_clock::now();
#endif
	run();
#ifdef Redshift_Debug
	auto ed = chrono::high_resolution_clock::now();
	fprintf(stderr, "%.9lf\n", (ed - st).count() / 1e9);
#endif
}

基本思路就是改成多层图然后跑最短路。

然后就不会了。T2 的区间变 00 可能会牵扯到两边的数而产生后效性,T3 的多括号匹配完全找不到思路。

今天可能就这样了。

Day 2

今天是社会活动。

在家做了一点高中数学必修一的题,打了会反物质,拿到了第二个无限维度并完成了第一个无限挑战。去刷了一些视频。信竞题好像一个都没做的样子。

Day 3

用了四个多小时写 T1,剩下的题目完全没看。

代码很长。

C++
#ifdef Redshift_Debug
#define debug(...) fprintf(stderr, __VA_ARGS__)
#include <chrono>
#else
#define debug(...)
#endif
#include <cstdio>
#include <iostream>
#include <string>
using namespace std;
const int N = 4e5 + 10;
using ll = long long;
int n, q, tps;
string s;
ll res;
struct st
{
	int ps0, ps1;
	bool l0, r0, sc0, l1, r1, sc1, l10, l01, r10, r01, exc101, exc010, tag;
	st operator+(const st &x) const
	{
		return st{min(ps0, x.ps0),
				  min(ps1, x.ps1),
				  l0,
				  x.r0,
				  sc0 or x.sc0 or (r0 and x.l0),
				  l1,
				  x.r1,
				  sc1 or x.sc1 or (r1 and x.l1),
				  l10,
				  l01,
				  x.r10,
				  x.r01,
				  exc010 or x.exc010 or (r0 and x.l10) or (r01 and x.l1),
				  exc101 or x.exc101 or (r1 and x.l01) or (r10 and x.l0),
				  false};
	}
	void flip()
	{
		swap(ps0, ps1);
		swap(l0, l1);
		swap(r0, r1);
		swap(sc0, sc1);
		swap(l10, l01);
		swap(r10, r01);
		swap(exc010, exc101);
		tag ^= 1;
	}
} tr[N << 2];
void init_global()
{
	cin.tie(0);
	cout.tie(0);
	ios::sync_with_stdio(0);
}
void build(int x, int l, int r)
{
	if (l == r)
	{
		tr[x] = st{(s[l] == '0' ? l : n),
				   (s[l] == '1' ? l : n),
				   (s[l] == '0'),
				   (s[l] == '0'),
				   false,
				   (s[l] == '1'),
				   (s[l] == '1'),
				   false,
				   false,
				   false,
				   false,
				   false,
				   false,
				   false,
				   false};
		return;
	}
	int mid = (l + r) >> 1;
	build(x << 1, l, mid);
	build(x << 1 | 1, mid + 1, r);
	tr[x] = tr[x << 1] + tr[x << 1 | 1];
	if (l == mid)
		tr[x].l01 |= (tr[x << 1].r0 and tr[x << 1 | 1].l1), tr[x].l10 |= (tr[x << 1].r1 and tr[x << 1 | 1].l0);
	if (r == mid + 1)
		tr[x].r01 |= (tr[x << 1].r0 and tr[x << 1 | 1].l1), tr[x].r10 |= (tr[x << 1].r1 and tr[x << 1 | 1].l0);
}
void init_local()
{
	cin >> n >> q;
	cin >> s;
	if (n != s.size())
		s = s.substr(s.size() - n);
	build(1, 0, n - 1);
}
void psh(int x)
{
	tr[x << 1].flip(), tr[x << 1 | 1].flip();
	tr[x].tag = false;
}
void update(int x, int l, int r, int lb, int rb)
{
	if (l >= lb and r <= rb)
	{
		tr[x].flip();

		return;
	}
	if (tr[x].tag)
		psh(x);
	int mid = (l + r) >> 1;
	if (lb <= mid)
		update(x << 1, l, mid, lb, rb);
	if (rb > mid)
		update(x << 1 | 1, mid + 1, r, lb, rb);
	tr[x] = tr[x << 1] + tr[x << 1 | 1];
	if (l == mid)
		tr[x].l01 |= (tr[x << 1].r0 and tr[x << 1 | 1].l1), tr[x].l10 |= (tr[x << 1].r1 and tr[x << 1 | 1].l0);
	if (r == mid + 1)
		tr[x].r01 |= (tr[x << 1].r0 and tr[x << 1 | 1].l1), tr[x].r10 |= (tr[x << 1].r1 and tr[x << 1 | 1].l0);
}
int qrysc1(int x, int l, int r)
{
	if (l != r and tr[x].tag)
		psh(x);
	int mid = (l + r) >> 1;
	int ret = 0;
	if (tr[x << 1].sc1)
		ret = qrysc1(x << 1, l, mid);
	else if (tr[x << 1].r1 and tr[x << 1 | 1].l1)
		ret = mid + 1;
	else
		ret = qrysc1(x << 1 | 1, mid + 1, r);
	tr[x] = tr[x << 1] + tr[x << 1 | 1];
	if (l == mid)
		tr[x].l01 |= (tr[x << 1].r0 and tr[x << 1 | 1].l1), tr[x].l10 |= (tr[x << 1].r1 and tr[x << 1 | 1].l0);
	if (r == mid + 1)
		tr[x].r01 |= (tr[x << 1].r0 and tr[x << 1 | 1].l1), tr[x].r10 |= (tr[x << 1].r1 and tr[x << 1 | 1].l0);
	return ret;
}
int qryp0(int x, int l, int r, int tar)
{
	if (l >= tar)
		return tr[x].ps0;
	if (tr[x].tag)
		psh(x);
	int mid = (l + r) >> 1;
	if (tar > mid)
		return qryp0(x << 1 | 1, mid + 1, r, tar);
	return min(qryp0(x << 1, l, mid, tar), tr[x << 1 | 1].ps0);
}
void run()
{
	res = 0;
	if (tr[1].sc1)
	{
		tps = qrysc1(1, 0, n - 1);
		res = max((int)tr[1].exc101, n - qryp0(1, 0, n - 1, tps + 1));
	}
	else if (tr[1].exc101)
		res ^= 1;
	for (int i = 1, l, r; i <= q; i++)
	{
		cin >> l >> r;
		l--, r--;
		update(1, 0, n - 1, l, r);
		if (tr[1].sc1)
		{
			tps = qrysc1(1, 0, n - 1);
			res ^= 1ll * (i + 1) * max((int)tr[1].exc101, n - qryp0(1, 0, n - 1, tps + 1));
		}
		else if (tr[1].exc101)
			res ^= (i + 1);
	}
	cout << res << '\n';
}
int main()
{
#ifdef Redshift_Debug
	auto st = chrono::high_resolution_clock::now();
#endif
	int T = 1;
	init_global();
	cin >> T >> T;
	while (T--)
	{
		init_local();
		run();
	}
#ifdef Redshift_Debug
	auto ed = chrono::high_resolution_clock::now();
	fprintf(stderr, "%.9lf\n", (ed - st).count() / 1e9);
#endif
}

大概没人会写跟我一样恶臭的线段树了。

剩下的摆了。


总分 0+0+[0,100]+0+0+[0,100]+0+0=[0,200]0+0+[0,100]+0+0+[0,100]+0+0=[0,200] 分。

每个题目的暴力都有一点分,如果是在赛场上我大概会尽全力拼一点分,但是这几天我都没离开过家,没有开 vp 模式,也没有一个好的竞技状态,于是就这样了。

原文