对拍无果WhyWA
查看原帖
对拍无果WhyWA
743373
Vitamin_B楼主2024/6/20 20:37

rt,https://www.luogu.com.cn/record/162638882,WhyWA?

# pragma GCC optimize("Ofast,no-stack-protector")

# pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

# include <bits/stdc++.h>

using namespace std;

typedef long long ll;

typedef pair <int, int> pii;

int n, m, x, y, dis[1005];

vector <pii> v[1005];

bitset <1005> vis;

queue <int> q;

int main () {

	ios::sync_with_stdio (0);

	cin.tie (0);

	cout.tie (0);

	cin >> m;

	while (m --) {

		cin >> x >> y;

		v[x].push_back ({y + 1, 1});

		n = max (n, y + 1);

	}
//	cerr << n << '\n';
	for (int i = 0; i < n; ++ i)
		v[i].push_back ({i + 1, 0}), v[i + 1].push_back ({i, -1});

	q.push (0);
//	for (int i = 0; i <= n; ++ i) for (pii& j : v[i]) cerr << i << "->" << j.first << ':' << j.second << '\n';
//	return 0;
	while (! q.empty ()) {

		x = q.front ();

		q.pop ();
		cerr << x << ':' << dis[x] << '\n';
		vis[x] = 0;

		for (pii& i : v[x])
			if (i.second + dis[x] > dis[i.first]) {

				dis[i.first] = dis[x] + i.second;

				if (! vis[i.first])
					q.push (i.first), vis[i.first] = 1;

			}

	}
//	for (int i = 1; i < n; ++ i) if (dis[i]) cerr << i << '\n';
	cout << dis[n] << '\n';

	for (int i = 0; i < n; ++ i)
		if (dis[i + 1] > dis[i])
			cout << i << ' ';

	return 0;

}

顺便捞1

顺便捞2

2024/6/20 20:37
加载中...