惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

月光博客
月光博客
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
N
Netflix TechBlog - Medium
大猫的无限游戏
大猫的无限游戏
爱范儿
爱范儿
Martin Fowler
Martin Fowler
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
The Register - Security
The Register - Security
IT之家
IT之家
博客园_首页
Microsoft Security Blog
Microsoft Security Blog
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
博客园 - 三生石上(FineUI控件)
I
InfoQ
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
Jina AI
Jina AI
Apple Machine Learning Research
Apple Machine Learning Research
M
MIT News - Artificial intelligence
博客园 - Franky
C
Check Point Blog
T
The Blog of Author Tim Ferriss
V
Visual Studio Blog
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
T
Tailwind CSS Blog
Recent Announcements
Recent Announcements
云风的 BLOG
云风的 BLOG
美团技术团队
The Cloudflare Blog
Y
Y Combinator Blog
H
Hackread – Cybersecurity News, Data Breaches, AI and More
MyScale Blog
MyScale Blog
The GitHub Blog
The GitHub Blog
D
DataBreaches.Net
Google DeepMind News
Google DeepMind News
V
V2EX
aimingoo的专栏
aimingoo的专栏
GbyAI
GbyAI
G
Google Developers Blog
S
SegmentFault 最新的问题
Hugging Face - Blog
Hugging Face - Blog
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
U
Unit 42
罗磊的独立博客
量子位
MongoDB | Blog
MongoDB | Blog
Last Week in AI
Last Week in AI
Stack Overflow Blog
Stack Overflow Blog
小众软件
小众软件
D
Docker
人人都是产品经理
人人都是产品经理

Shiroha白羽的博客

Golang 踩坑 —— interface 为参数的时候传 nil 指针 Codeforces Round 925 (Div. 3) Codeforces Round 923 (Div. 3) Codeforces Round 922 (Div. 2) Codeforces Round 921 (Div. 2) Educational Codeforces Round 161 (Rated for Div. 2) Codeforces Round 920 (Div. 3) Codeforces Round 919 (Div. 2) Hello 2024 Good Bye 2023 Codeforces Round 918 (Div. 4) 个人备份的常用 macOS 清理命令 Codeforces Round 917 (Div. 2) Pinely Round 3 (Div. 1 + Div. 2) Educational Codeforces Round 160 (Rated for Div. 2) Codeforces Round 915 (Div. 2) Codeforces Round 914 (Div. 2) Codeforces Round 913 (Div. 3) Educational Codeforces Round 159 (Rated for Div. 2) Codeforces Round 912 (Div. 2) Codeforces Round 911 (Div. 2) CodeTON Round 7 (Div. 1 + Div. 2, Rated, Prizes!) Educational Codeforces Round 158 (Rated for Div. 2) Codeforces Round 910 (Div. 2) Codeforces Round 909 (Div. 3) Codeforces Round 908 (Div. 2) Educational Codeforces Round 157 (Rated for Div. 2) C++自定义的字面量 Codeforces Round 907 (Div. 2) Codeforces Round 916 (Div. 3) 关于 LRU map 的一些灵感 2023 杭州站 ICPC 现场赛 反复横跳的 Clang-Tidy(cert-dcl21-cpp) Codeforces Round 906 (Div. 2) 一段奇怪的 CPP 代码 Codeforces Round 905 (Div. 3) Codeforces Round 904 (Div. 2) Codeforces Round 903 (Div. 3) Educational Codeforces Round 156 (Rated for Div. 2) Codeforces Round 902 (Div. 2, based on COMPFEST 15 - Final Round) Codeforces Round 901 (Div. 2) Codeforces Round 900 (Div. 3) Codeforces Round 899 (Div. 2) Educational Codeforces Round#155 (Div. 2) Codeforces Round 898 (Div. 4) CodeTON Round 6 (Div. 2) Codeforces Round 897 (Div. 2) Codeforces Round 896 (Div. 2) Codeforces Round 887 (Div. 2) Codeforces Round 895 (Div. 3) 左值-右值-将亡值 blog.mauve.icu Pinely Round 2 (Div. 1 + Div. 2) Harbour.Space Scholarship Contest 2023-2024 (Div. 1 + Div. 2) Codeforces Round 894 (Div. 3) Codeforces Round 888 (Div. 3) Educational Codeforces Round#153 (Div. 2) Codeforces Round 893 (Div. 2) OTPAUTH,两步验证中的通用协议 Codeforces Round 892 (Div. 2) Codeforces Round 891 (Div. 3) Codeforces Round 890 (Div. 2) Educational Codeforces Round#152 (Div. 2) blog.mauve.icu Java Script 的 null 和 undefined 随想 记一次 SQL LEFT JOIN 没有得到预期结果的错误 Codeforces Round#789(Div. 2) GCC/G++ 预编译头性能优化 使用 Junit5 和 Mockito 实现 SpringBoot 的单元测试最优美的解决方案 centOS 防火墙 docker-compse 的问题 C++ 语言实现动态变化的线程池 Codeforces Round#744 (Div. 3) 计算机图形学 Windows 通过网络访问 WSL2 原生 JavaScript 实现图片裁剪 面试复习(计算机图形学) 面试复习(算法) Codeforces Round#706(Div. 2)-Let's Go Hiking 面试复习(Java) 面试复习(Git) 面试复习(Linux) 面试复习(数据库) 面试复习(计算机网络) 面试复习(操作系统) 面试复习(C++) Codeforces Round#699 (Div. 2) 清理 WSL2 的磁盘占用 Codeforces Round#697 (Div. 3) Windows 下的 NTFS 驱动器索引 BUG 计算机网络复习 记一次 Navicat 连接 MySQL 一直报认证错误(Access denied) 计算机网络实验复习 WSL1 使用 Docker 一直无法启动 我的ACM脚印 2020牛客暑期多校训练营(第三场)D-Points Construction Problem——构造 2020牛客暑期多校训练营(第三场)E-Two Matchings——复杂思维与简单dp 2020牛客暑期多校训练营(第二场)I-Interval——最大流转对偶图求最短路 Educational Codeforces Round 80 D. Minimax Problem——二分+二进制处理 Codeforces Round 606 E. Two Fairs——图论 Codeforces Round 612 (Div. 2) C. Garland——DP
Codeforces Round 924 (Div. 2)
Shiroha · 2024-04-05 · via Shiroha白羽的博客

A. Rectangle Cutting

大致题意

有一个矩型,将其切割成两半,然后再拼接起来,问是否可能得到另外一个矩型

思路

简单题,直接尝试一下就行了

AC code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
void solve() {
int _;
cin >> _;
for (int tc = 0; tc < _; ++tc) {
int a, b;
cin >> a >> b;
bool flag = false;
if (a % 2 == 0) {
int ra = a / 2, rb = b * 2;
if (ra != b || rb != a) flag = true;
}
if (b % 2 == 0) {
int ra = a * 2, rb = b / 2;
if (ra != b || rb != a) flag = true;
}
cout << (flag ? "YES" : "No") << endl;
}
}

B. Equalize

大致题意

已知一个数组,现在将一个等长的排列加到这个数组上,问最多出现多少个相同的值

思路

等价于在长度为 $n$ 的值范围内,原始数组有多少个不同的值

AC code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
void solve() {
int _;
cin >> _;
for (int tc = 0; tc < _; ++tc) {
int n;
cin >> n;
vector<int> data(n);
for (auto& i: data) cin >> i;
sort(data.begin(), data.end());
int end = (int)(unique(data.begin(), data.end()) - data.begin());
int l = 0, ans = 0;
for (int r = 0; r < end; ++r) {
while (data[r] - data[l] >= n) ++l;
ans = max(ans, r - l + 1);
}
cout << ans << endl;
}
}

C. Physical Education Lesson

大致题意

有一个数组,其值类似一个波长为 $x$ 的波,从 $1 \rightarrow k \rightarrow 1$,现在只知道第 $n$ 的位置是 $x$,问有多种不同的波的可能

思路

AC code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
void solve() {
int _;
cin >> _;
for (int tc = 0; tc < _; ++tc) {
int x, n, v[2];
cin >> x >> n;
// upside
v[0] = x - n;
// downside
v[1] = x + n - 2;
set<int> st;

auto add = [&](int x) {
if (x % 2 || x < n * 2 - 2) return;
st.insert(x);
};
auto cal = [&](int x) {
int r = min((int)sqrt(x) + 10, x);
for (int i = 1; i < r; ++i) if (x % i == 0) {
add(i);
add(x / i);
}
};

cal(v[0]);
cal(v[1]);

cout << st.size() << endl;
}
}

D. Lonely Mountain Dungeons

大致题意

有 $n$ 个不同的种族,每个种族有不同数量的士兵,现在需要将它们组成 $k$ 只军队,每个士兵必定属于某一个军队

每多创建一个军队,其就要减少 $x$ 的战斗力,而当同一个种族的两个士兵被分配到不同的队伍的情况下,则会增加 $b$ 单位的战斗力

问最大的战斗力可能是多少

思路

三分一下队伍数量即可

AC code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#define int long long

void solve() {
int _;
cin >> _;
for (int tc = 0; tc < _; ++tc) {
int n, b, x;
cin >> n >> b >> x;
vector<int> c(n);
for (auto &i: c) cin >> i;
int l = 1, r = 2e5 + 10;

auto check = [&](int mid) {
int res = -x * (mid - 1);
for (const auto &i: c) {
int v = i / mid, c1 = i % mid, c2 = mid - c1;
res += b * c1 * (v + 1) * (i - v - 1) / 2;
res += b * c2 * v * (i - v) / 2;
}
return res;
};

while (l + 10 < r) {
int ml = (2 * l + r) / 3, mr = (l + 2 * r) / 3;
int rl = check(ml), rr = check(mr);
if (rl < rr) l = ml;
else r = mr;
}

int ans = 0;
for (int i = l; i <= r; ++i)
ans = max(ans, check(i));
cout << ans << endl;
}
}

E. Modular Sequence

大致题意

有一个数组,第一个值已经确定,其后的每一个值的,等于前一个值 $+ y$ 或者等于 $mod \space y$,且已知长度和总和,问是否存在这样的数组

思路

容易得到,最终因为变化都和 $y$ 有关,所以 $x \space y$ 这部分的值,必然会被每一个单位所保留,即每一个值必定等价于 $t \times y + x \space mod \space y$

所以可以先 $s \leftarrow $,那么所有值就等于 $t \times y$

再统一除以 $y$ 可以得到 $s \leftarrow \frac{s - n \times (x \space mod \space y)}{y}$ 而数组则是几个递增的阶梯($0, 1, 2, \dots$)组成

所以只需要求解阶梯的数量和每个阶梯的长度即可

容易得到一个简单的结论:最长的阶梯不超过 $650$,因为 $(1 + 650) \times 650 / 2 = 211575$,所以可以通过暴力的手段解决

定义 dp[i] 表示当前 $s$ 还剩下 $i$ 个值需要处理的时候,已经消耗了多少个位置,对于每一个 $i$,暴力遍历 $650$ 种可能性即可

AC code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
void solve() {
int _;
cin >> _;
for (int tc = 0; tc < _; ++tc) {
int n, x, y, s;
cin >> n >> x >> y >> s;

if ((s - n * (x % y)) % y || (x % y) * n > s || x > s) {
cout << "NO" << endl;
continue;
}
int rs = (s - n * (x % y)) / y;
int st = x / y - 1;
if (x / y > rs) {
cout << "NO" << endl;
continue;
}

vector<pair<int, int>> dp(rs + 1, {0x3fffffff, -1});
dp[rs] = {0, -1};
for (int i = st + 1, tmp = 0; i <= s; ++i) {
tmp += i;
if (tmp == 0) continue;
if (rs - tmp < 0) break;
dp[rs - tmp] = {i, rs};
}
for (int i = rs - 1; i >= 1; --i)
for (int j = 1; j < 623; ++j) {
if (i - (1 + j) * j / 2 < 0) break;
if (dp[i - (1 + j) * j / 2].first <= dp[i].first + j + 1) continue;
dp[i - (1 + j) * j / 2] = {dp[i].first + j + 1, i};
}
if (st + n < dp[0].first) {
cout << "NO" << endl;
continue;
}
cout << "YES" << endl;
int cur = 0;
vector<int> res;
while (~cur) {
if (dp[cur].second != -1) res.push_back(dp[cur].second - cur);
cur = dp[cur].second;
if (res.size() > 100) {
cerr << 1;
}
}
reverse(res.begin(), res.end());
int index = 0;
for (int i = 0; i < res.size(); ++i) {
int cost = 0, j = i == 0 ? st + 1 : 0;
while (cost <= res[i]) {
cout << j * y + x % y << ' ';
++index;
++j;
cost += j;
}
}
while (index < n) {
cout << x % y << ' ';
++index;
}
cout << endl;
}
}