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

推荐订阅源

Google DeepMind News
Google DeepMind News
Attack and Defense Labs
Attack and Defense Labs
GbyAI
GbyAI
月光博客
月光博客
Recent Announcements
Recent Announcements
云风的 BLOG
云风的 BLOG
F
Full Disclosure
宝玉的分享
宝玉的分享
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
爱范儿
爱范儿
博客园 - Franky
V
V2EX
Recorded Future
Recorded Future
WordPress大学
WordPress大学
小众软件
小众软件
Webroot Blog
Webroot Blog
雷峰网
雷峰网
Vercel News
Vercel News
N
News and Events Feed by Topic
PCI Perspectives
PCI Perspectives
Cyberwarzone
Cyberwarzone
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
W
WeLiveSecurity
S
Schneier on Security
博客园 - 三生石上(FineUI控件)
K
Kaspersky official blog
F
Fortinet All Blogs
Security Archives - TechRepublic
Security Archives - TechRepublic
Spread Privacy
Spread Privacy
博客园 - 叶小钗
罗磊的独立博客
D
Docker
Forbes - Security
Forbes - Security
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
The Register - Security
The Register - Security
A
About on SuperTechFans
B
Blog RSS Feed
I
InfoQ
T
Tailwind CSS Blog
G
Google Developers Blog
H
Help Net Security
V
Vulnerabilities – Threatpost
AWS News Blog
AWS News Blog
N
News and Events Feed by Topic
M
MIT News - Artificial intelligence
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
P
Proofpoint News Feed
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
MyScale Blog
MyScale Blog
Latest news
Latest news

Shiroha白羽的博客

Golang 踩坑 —— interface 为参数的时候传 nil 指针 Codeforces Round 925 (Div. 3) Codeforces Round 924 (Div. 2) 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 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 905 (Div. 3)
Shiroha · 2023-11-27 · via Shiroha白羽的博客

A. Morning

大致题意

需要依次打出四个数字,键盘上有十个按钮,每个按钮对应一个数字,每次允许按下当前按钮,或者移动到相邻的按钮上,问至少需要多少次才能打出来

思路

暴力扫都行,模拟顺序然后找路径即可

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 ts = 0; ts < _; ++ts) {
int x;
cin >> x;

int d[5], ans = 0;
for (int &i: d) {
i = x % 10;
if (i == 0) i = 10;
x /= 10;
}
d[4] = 1;
for (int i = 3; i >= 0; --i) ans += abs(d[i] - d[i + 1]) + 1;
cout << ans << endl;
}
}

B. Chemistry

大致题意

给你一个字符串,在恰好删除掉 $k$ 个字母之后,再重新排列,能否得到一个回文串

思路

只要 $k$ 至少比字母出现次数为基数次的字母个数 $- 1$ 还要多就行了

AC code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
void solve() {
int _;
cin >> _;

string str;
str.reserve(1e5 + 10);
for (int ts = 0; ts < _; ++ts) {
int n, k;
cin >> n >> k >> str;
map<char, int> cnt;
for (auto &item: str) cnt[item]++;
int edd = 0;
for (auto &item: cnt) edd += item.second % 2;
cout << ((k >= edd - 1) ? "YES" : "NO") << endl;
}
}

C. Raspberries

大致题意

有一个数组,和一个 $k$,每次操作可以将数组上的某一个值 $+ 1$,问至少需要操作几次,才能让数组的所有值乘积是 $k$ 的倍数

思路

注意题目给出的 $k$ 的范围,仅有可能是 $[2, 5]$,这其中还恰好基本都是素数,仅 $4$ 不是,所以基本上都是其中单个值满足倍数关系了

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
void solve() {
int _;
cin >> _;
for (int ts = 0; ts < _; ++ts) {
int n, k;
cin >> n >> k;
vector<int> data(n);
for (auto &i: data) cin >> i;
if (k != 4) {
int mi = k, ma = 0;
for (auto &i: data) {
mi = min(mi, i % k);
ma = max(ma, i % k);
}
if (mi == 0) cout << 0 << endl;
else cout << (k - ma) << endl;
} else {
int even = 0, ma = 0;
for (auto &i: data) {
even += i % 4 == 0 ? 2 : i % 2 == 0;
ma = max(ma, i % 4);
}
cout << min(max(0, 2 - even), 4 - ma) << endl;
}
}
}

D. In Love

大致题意

有一个线段的集合,每次往里面加一个线段或者删除一个线段,问每次操作后,是否存在两个线段他们不重叠

思路

也很简单,维护好线段右边最小的和线段左边最大的两个堆即可

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
void solve() {
int n;
cin >> n;
priority_queue<pair<int, int>, vector<pair<int, int>>, less<>> prq1;
priority_queue<pair<int, int>, vector<pair<int, int>>, greater<>> prq2;
map<int, int> mvd1, mvd2;

for (int i = 0; i < n; ++i) {
char op;
int l, r;
cin >> op >> l >> r;
if (op == '+') {
prq1.emplace(l, i);
prq2.emplace(r, i);
} else {
mvd1[l]++;
mvd2[r]++;
}

while (!prq1.empty()) {
auto item = prq1.top();
auto iter = mvd1.find(item.first);
if (iter != mvd1.end()) {
while (iter->second--) prq1.pop();
mvd1.erase(iter);
} else break;
}
while (!prq2.empty()) {
auto item = prq2.top();
auto iter = mvd2.find(item.first);
if (iter != mvd2.end()) {
while (iter->second--) prq2.pop();
mvd2.erase(iter);
} else break;
}

if (prq1.empty() || prq2.empty() || prq1.size() == 1 || prq2.size() == 1) cout << "NO" << endl;
else cout << (prq1.top().first > prq2.top().first ? "YES" : "NO") << endl;
}
}

E. Look Back

大致题意

有一个数组,每次可以让其中一个值翻倍,问至少操作多少次,才能让整个数组不递减

思路

这道题从二进制角度考虑就很简单。

翻倍其实就是左移一位,所以如果两个值本身的最高的比特位置相同,那么如果这两个值仍然存在前者大于后者的情况,那么后者需要在前者左移的基础上,再左移一位即可。反之则和前者左移次数相同即可

问题是如何构造最高比特位相同的数组。我们可以先人工把所有值都左移到某个位置,到时候再右移回来即可

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
#define int long long

void solve() {
int _;
cin >> _;
for (int ts = 0; ts < _; ++ts) {
int n;
cin >> n;
vector<int> data(n), p(n, 0), ans(n, 0);
for (auto &i: data) cin >> i;
for (int i = 0; i < n; ++i) {
while (data[i] <= INT_MAX) {
p[i]++;
data[i] <<= 1;
}
}
for (int i = 1; i < n; ++i) ans[i] = ans[i - 1] + (data[i] >= data[i - 1] ? 0 : 1);
int last = p[0] + ans[0], tot = 0;
for (int i = 0; i < n; ++i) {
ans[i] += p[i];
last = min(ans[i], last);
ans[i] -= last;
tot += ans[i];
}

cout << tot << endl;
}
}

F. You Are So Beautiful

大致题意

给你一个数组,问是否存在这样的一个子串,满足不同时存在两个子序列和这个子串相同,问有多少个这样的子串

思路

注意题目要找的是子串。说白了也很简单,只需要这个子串最左边的值是原串中这个值最左边的,右边也同样,即可

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
#define int long long

void solve() {
int _;
cin >> _;
for (int ts = 0; ts < _; ++ts) {
int n;
cin >> n;
vector<int> data(n);
for (auto &i: data) cin >> i;
map<int, int> cnt[2];
for (auto &i: data) cnt[1][i]++;
int ans = 0;
for (auto &i: data) {
auto iter = cnt[1].find(i);
iter->second--;
if (iter->second == 0) cnt[1].erase(iter);

// left has
if (cnt[0].count(i)) continue;
ans += (int) cnt[1].size();

// single
if (iter->second == 0) ans++;

cnt[0][i]++;
}

cout << ans << endl;
}
}

G2. Dances (Hard Version)

直接看 hard 版本吧,其实都挺简单的,感觉这场最有意思的应该是是 E 题

大致题意

有两个数组,其中数组 $a$ 的某一个值可以是 $[1, m]$ 中任意一个。允许你每次操作同时从数组中删除掉一个值,操作完成后再重新排列数组,问是否可以满足数组 $b$ 的每一项都 $> a$

思路

贪心一下就行了,说白了就是从 $b$ 里找第一个大于等于每一个 $a$ 的值即可。然后剩下的值都删掉

至于那个特殊的值?可以在剩下要删掉的里面取最大的那个,如果那个特殊值小于它的时候,则不用删,否则删除

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
void solve() {
int _;
cin >> _;
for (int ts = 0; ts < _; ++ts) {
int n, m;
cin >> n >> m;
vector<int> a(n - 1), b(n);
for (auto &i: a) cin >> i;
for (auto &i: b) cin >> i;
sort(a.begin(), a.end());
sort(b.begin(), b.end());

int lastB = -1, base = 0, cur = 0;
for (int &i: a) {
while (cur < n && i >= b[cur]) lastB = b[cur++];
if (cur >= n) base++;
cur++;
}
if (lastB == -1) lastB = b.back();

cout << 1LL * base * m + max(0, m - lastB + 1) << endl;
}
}