跳到正文

个人记录

模拟赛挂分日记

CrystalCore约 21 分钟
原文
文章信息与版本

文章信息

收录
2025年12月12日
更新
2025年12月24日
篇幅
约 21 分钟

版本

  1. v2当前
  2. v1

模拟赛挂分日记

2025/11/8

T1

原代码:

C++
#include <bits/stdc++.h>
#define ll long long
#define str string
#define db double
using namespace std;
constexpr ll MAXN = 1e5 + 5;
ll n, a[MAXN];
db ans = 1e7;
int main() {
	freopen("village.in", "r", stdin);
	freopen("village.out", "w", stdout);
	scanf("%lld", &n);
	for (ll i = 1; i <= n; ++i)
		scanf("%lld", a + i);
	sort(a + 1, a + n + 1);
	for (ll i = 2; i < n; ++i)
		ans = min(ans, (db)((a[i + 1] + a[i]) / 2.0) - ((a[i - 1] + a[i]) / 2.0));
	printf("%.1f\n", ans);
	return 0;
}

修改后:

C++
#include <bits/stdc++.h>
#define ll long long
#define str string
#define db double
using namespace std;
constexpr ll MAXN = 1e5 + 5;
ll n, a[MAXN];
db ans = 1e9;
int main() {
	freopen("village.in", "r", stdin);
	freopen("village.out", "w", stdout);
	scanf("%lld", &n);
	for (ll i = 1; i <= n; ++i)
		scanf("%lld", a + i);
	sort(a + 1, a + n + 1);
	for (ll i = 2; i < n; ++i)
		ans = min(ans, (db)((a[i + 1] + a[i]) / 2.0) - ((a[i - 1] + a[i]) / 2.0));
	printf("%.1f\n", ans);
	return 0;
}

修改内容:

C++
db ans = 1e7;

改为:

C++
db ans = 1e9;

分数变化:60 -> 100

T3

原代码:

C++
#include <bits/stdc++.h>
#define ll long long
using namespace std;
static char buf[1 << 20], *p(0), *top(0);
#define getchar() (p == top && (top = (p = buf) + fread(buf, 1, sizeof buf, stdin)), *p++)
namespace FastIO {
template <typename T>
inline void read(T& x) {
	x = 0;
	int f = 1;
	char c = getchar();
	while (c < '0' || c > '9') {
		if (c == '-')
			f = -1;
		c = getchar();
	}
	while (c >= '0' && c <= '9') {
		x = (x << 1) + (x << 3) + (c ^ 48);
		c = getchar();
	}
	x *= f;
}
template <typename T, typename... Args>
inline void read(T& x, Args&... args) {
	read(x);
	read(args...);
}
template <typename T>
inline void write(T x) {
	if (x < 0)
		x = -x, putchar('-');
	if (x > 9)
		write(x / 10);
	putchar(x % 10 + 48);
}
} // namespace FastIO
using namespace FastIO;
constexpr ll N = 1e6 + 5;
ll n, c, x, w, ans, mp[N], sum[N];
int main() {
	freopen("flower.in", "r", stdin);
	freopen("floewr.out", "w", stdout);
	read(n, c);
	for (ll i = 1; i <= n; ++i)
		read(x), mp[x]++;
	for (ll i = 0; i < c / 2; ++i)
		w += mp[i];
	ans = n * (n - 1) * (n - 2) / 6;
	for (ll i = 0; i < c; ++i) {
		w = w - mp[i] + mp[(i + c / 2) % c];
		if (mp[i] == 0)
			continue;
		ans -= mp[i] * w * (w - 1) / 2;
		ans -= mp[i] * (mp[i] - 1) / 2 * w;
		ans -= mp[i] * (mp[i] - 1) * (mp[i] - 2) / 6;
		if (!(c & 1))
			ans += mp[i] * (mp[i] - 1) / 2 * mp[(i + c / 2) % c];
	}
	write(ans), putchar('\n');
	return 0;
}

修改后:

C++
#include <bits/stdc++.h>
#define ll long long
using namespace std;
static char buf[1 << 20], *p(0), *top(0);
#define getchar() (p == top && (top = (p = buf) + fread(buf, 1, sizeof buf, stdin)), *p++)
namespace FastIO {
template <typename T>
inline void read(T& x) {
	x = 0;
	int f = 1;
	char c = getchar();
	while (c < '0' || c > '9') {
		if (c == '-')
			f = -1;
		c = getchar();
	}
	while (c >= '0' && c <= '9') {
		x = (x << 1) + (x << 3) + (c ^ 48);
		c = getchar();
	}
	x *= f;
}
template <typename T, typename... Args>
inline void read(T& x, Args&... args) {
	read(x);
	read(args...);
}
template <typename T>
inline void write(T x) {
	if (x < 0)
		x = -x, putchar('-');
	if (x > 9)
		write(x / 10);
	putchar(x % 10 + 48);
}
} // namespace FastIO
using namespace FastIO;
constexpr ll N = 1e6 + 5;
ll n, c, x, w, ans, mp[N], sum[N];
int main() {
	freopen("flower.in", "r", stdin);
	freopen("flower.out", "w", stdout);
	read(n, c);
	for (ll i = 1; i <= n; ++i)
		read(x), mp[x]++;
	for (ll i = 0; i < c / 2; ++i)
		w += mp[i];
	ans = n * (n - 1) * (n - 2) / 6;
	for (ll i = 0; i < c; ++i) {
		w = w - mp[i] + mp[(i + c / 2) % c];
		if (mp[i] == 0)
			continue;
		ans -= mp[i] * w * (w - 1) / 2;
		ans -= mp[i] * (mp[i] - 1) / 2 * w;
		ans -= mp[i] * (mp[i] - 1) * (mp[i] - 2) / 6;
		if (!(c & 1))
			ans += mp[i] * (mp[i] - 1) / 2 * mp[(i + c / 2) % c];
	}
	write(ans), putchar('\n');
	return 0;
}

修改内容:

C++
	freopen("floewr.out", "w", stdout);

改为:

C++
	freopen("flower.out", "w", stdout);

分数变化:0 -> 100

2025/11/11

T1

原代码:

C++
#include <bits/stdc++.h>
#define ll long long
#define str string
#define db double
using namespace std;
constexpr ll MAXN = 1e5 + 5;
ll n, k, all, a[MAXN], qzh[MAXN], hzh[MAXN];
class node {
public:
	ll vl;
	inline bool operator<(const node& x) const { return vl > x.vl; }
};
priority_queue<node> q;
vector<ll> vec;
int main() {
	freopen("Ksum.in", "r", stdin);
	freopen("ksum.out", "w", stdout);
	ios::sync_with_stdio(false);
	cin.tie(nullptr), cout.tie(nullptr);
	cin >> n >> k;
	for (ll i = 1; i <= n; ++i)
		cin >> a[i], qzh[i] = qzh[i - 1] + a[i];
	for (ll i = n; i >= 1; i--)
		hzh[i] = hzh[i + 1] + a[i];
	sort(qzh + 1, qzh + n + 1, greater<ll>()), all = hzh[1];
	for (ll i = 1; i <= n; ++i)
		for (ll j = 1; i + j <= n + 1; ++j) {
			if (q.size() < k)
				q.emplace(node({qzh[i] + hzh[j]}));
			else if (qzh[i] + hzh[j] < q.top().vl)
				break;
			else
				q.emplace(node({qzh[i] + hzh[j]})), q.pop();
		}
	while (q.size())
		vec.emplace_back(q.top().vl - all), q.pop();
	sort(vec.begin(), vec.end(), greater<ll>());
	for (const ll& v : vec)
		cout << v << ' ';
	return 0;
}

修改后:

C++
#include <bits/stdc++.h>
#define ll long long
#define str string
#define db double
using namespace std;
constexpr ll MAXN = 1e5 + 5;
ll n, k, all, a[MAXN], qzh[MAXN], hzh[MAXN];
class node {
public:
	ll vl;
	inline bool operator<(const node& x) const { return vl > x.vl; }
};
priority_queue<node> q;
vector<ll> vec;
int main() {
	freopen("ksum.in", "r", stdin);
	freopen("ksum.out", "w", stdout);
	ios::sync_with_stdio(false);
	cin.tie(nullptr), cout.tie(nullptr);
	cin >> n >> k;
	for (ll i = 1; i <= n; ++i)
		cin >> a[i], qzh[i] = qzh[i - 1] + a[i];
	for (ll i = n; i >= 1; i--)
		hzh[i] = hzh[i + 1] + a[i];
	sort(qzh + 1, qzh + n + 1, greater<ll>()), all = hzh[1];
	for (ll i = 1; i <= n; ++i)
		for (ll j = 1; i + j <= n + 1; ++j) {
			if (q.size() < k)
				q.emplace(node({qzh[i] + hzh[j]}));
			else if (qzh[i] + hzh[j] < q.top().vl)
				break;
			else
				q.emplace(node({qzh[i] + hzh[j]})), q.pop();
		}
	while (q.size())
		vec.emplace_back(q.top().vl - all), q.pop();
	sort(vec.begin(), vec.end(), greater<ll>());
	for (const ll& v : vec)
		cout << v << ' ';
	return 0;
}

修改内容:

C++
	freopen("Ksum.in", "r", stdin);

改为

C++
	freopen("ksum.in", "r", stdin);

分数变化:0 -> 100

2025/11/13

T1

原代码:

C++
#include <bits/stdc++.h>
#define ll long long
#define str string
#define db double
using namespace std;
constexpr ll MAXN = 305;
ll t, n, d1, d2, a, b, all_a, all_b;
int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr), cout.tie(nullptr);
	cin >> t;
	while (t--) {
		cin >> n >> d1 >> d2;
		for (ll i = 1; i <= n; ++i)
			for (ll j = 1; j <= n; ++j)
				cin >> a, all_a += a;
		for (ll i = 1; i <= n; ++i)
			for (ll j = 1; j <= n; ++j)
				cin >> b, all_b += b;
		if (2 * all_a - 2 * all_b == d1 + d2)
			cout << "Yes" << '\n';
		else
			cout << "No" << '\n';
	}
	return 0;
}

修改后:

C++
#include <bits/stdc++.h>
#define ll long long
#define str string
#define db double
using namespace std;
constexpr ll MAXN = 305;
ll t, n, d1, d2, a, b, all_a, all_b;
int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr), cout.tie(nullptr);
	cin >> t;
	while (t--) {
		cin >> n >> d1 >> d2, all_a = 0, all_b = 0;
		for (ll i = 1; i <= n; ++i)
			for (ll j = 1; j <= n; ++j)
				cin >> a, all_a += a;
		for (ll i = 1; i <= n; ++i)
			for (ll j = 1; j <= n; ++j)
				cin >> b, all_b += b;
		if (2 * all_a - 2 * all_b == d1 + d2)
			cout << "Yes" << '\n';
		else
			cout << "No" << '\n';
	}
	return 0;
}

修改内容:

C++
		cin >> n >> d1 >> d2;

改为:

C++
		cin >> n >> d1 >> d2, all_a = 0, all_b = 0;

分数变化:0 -> 100

T4

不知道算不算挂分,我没看到非严格递增,就没写。 原代码:

C++
#include <bits/stdc++.h>
#define ll long long
#define str string
#define db double
using namespace std;
constexpr ll MAXN = 1005;
ll n, q, a[MAXN];
int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr), cout.tie(nullptr);
	cin >> n >> q;
	for (ll i = 1; i <= n; ++i)
		cin >> a[i];
	while (q--) {
		cout << (rand() % 2 ? "Yes" : "No") << '\n';
	}
	return 0;
}

修改后:

C++
#include <bits/stdc++.h>
#define ll long long
#define str string
#define db double
using namespace std;
constexpr ll MAXN = 1005;
ll n, q, a[MAXN];
inline bool work(ll k, ll wch, ll x) {
	ll l = a[wch], r = a[wch + 1], mid, flgl = 0, flgr = 0;
	if (l == x)
		return true;
	if (!wch || wch == n)
		return false;
	while (k--) {
		mid = (l + r) / 2;
		if (mid == x)
			return true;
		else if (mid > x)
			r = mid;
		else
			l = mid;
		if (flgl == l && flgr == r)
			break;
		flgl = l, flgr = r;
	}
	return false;
}
int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr), cout.tie(nullptr);
	cin >> n >> q;
	for (ll i = 1; i <= n; ++i)
		cin >> a[i];
	while (q--) {
		ll k, x, fnd, l, r;
		cin >> k >> x, fnd = upper_bound(a + 1, a + n + 1, x) - a - 1, l = a[fnd], r = a[fnd] + 1;
		cout << (work(k, fnd, x) ? "Yes" : "No") << '\n';
	}
	return 0;
}

修改幅度较大,就不一一展示了。 分数变化:0 -> 100

1025/11/19

T1

原代码:

C++
#include <bits/stdc++.h>
#define ll long long
#define str string
#define db double
using namespace std;
ll n, k, l, r, ans, cnt_0;
str s;
queue<ll> q;
int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr), cout.tie(nullptr);
	cin >> s >> k, n = s.size(), s = ' ' + s;
	for (l = 1; r <= n && l <= n; ++r) {
		if (s[r] == '0')
			q.emplace(r), cnt_0++;
		if (cnt_0 == k + 1)
			ans = max(ans, r - l), l = q.front() + 1, q.pop(), cnt_0--;
	}
	cout << ans << '\n';
	return 0;
}

修改后:

C++
#include <bits/stdc++.h>
#define ll long long
#define str string
#define db double
using namespace std;
ll n, k, l, r, ans, cnt_0;
str s;
queue<ll> q;
int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr), cout.tie(nullptr);
	cin >> s >> k, n = s.size(), s = ' ' + s;
	for (l = 0; r <= n && l <= n; ++r) {
		if (s[r] == '0')
			q.emplace(r), cnt_0++;
		if (cnt_0 == k + 1)
			l = q.front(), q.pop(), cnt_0--;
		ans = max(ans, r - l);
	}
	cout << ans << '\n';
	return 0;
}

修改内容:

C++
	for (l = 0; r <= n && l <= n; ++r) {

改为:

C++
	for (l = 1; r <= n && l <= n; ++r) {
C++
		if (cnt_0 == k + 1)
			ans = max(ans, r - l), l = q.front() + 1, q.pop(), cnt_0--;

改为

C++
		if (cnt_0 == k + 1)
			l = q.front(), q.pop(), cnt_0--;
		ans = max(ans, r - l);

分数变化:20 -> 100

希望大家引以为鉴,保护好自己的分数。

原文