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

推荐订阅源

AI
AI
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
Google DeepMind News
Google DeepMind News
T
Tenable Blog
博客园_首页
S
Securelist
Spread Privacy
Spread Privacy
Google Online Security Blog
Google Online Security Blog
Forbes - Security
Forbes - Security
Engineering at Meta
Engineering at Meta
U
Unit 42
L
LINUX DO - 热门话题
量子位
T
Threat Research - Cisco Blogs
博客园 - 【当耐特】
C
Cyber Attacks, Cyber Crime and Cyber Security
K
Kaspersky official blog
MyScale Blog
MyScale Blog
P
Proofpoint News Feed
The Last Watchdog
The Last Watchdog
Google DeepMind News
Google DeepMind News
GbyAI
GbyAI
Martin Fowler
Martin Fowler
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
Security Latest
Security Latest
Scott Helme
Scott Helme
V
Vulnerabilities – Threatpost
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
I
InfoQ
Know Your Adversary
Know Your Adversary
Cisco Talos Blog
Cisco Talos Blog
The Register - Security
The Register - Security
T
The Blog of Author Tim Ferriss
aimingoo的专栏
aimingoo的专栏
V2EX - 技术
V2EX - 技术
T
Tailwind CSS Blog
月光博客
月光博客
Recent Announcements
Recent Announcements
G
Google Developers Blog
F
Full Disclosure
W
WeLiveSecurity
宝玉的分享
宝玉的分享
腾讯CDC
G
GRAHAM CLULEY
Vercel News
Vercel News
Simon Willison's Weblog
Simon Willison's Weblog
美团技术团队
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
Help Net Security
Help Net Security

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) 一段奇怪的 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 906 (Div. 2)
Shiroha · 2023-12-03 · via Shiroha白羽的博客

A. Doremy’s Paint 3

大致题意

有一个数组,重排之后,是否能够满足任意两个相邻值的只和都相同

思路

只有两种可能,只有两个值,且数量相同或者恰好差一个,或者只有一个值

AC code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
void solve() {
int _;
cin >> _;
for (int ts = 0; ts < _; ++ts) {
int n;
cin >> n;
map<int, int> mp;
for (int i = 0; i < n; ++i) {
int tmp;
cin >> tmp;
mp[tmp]++;
}

if (mp.size() == 1) cout << "YES" << endl;
else if (mp.size() > 2) cout << "NO" << endl;
else {
cout << (abs(mp.begin()->second - mp.rbegin()->second) <= 1 ? "YES" : "NO")<< endl;
}
}
}

B. Qingshan Loves Strings

大致题意

有两个 $01$ 字符串,希望把 $A$ 字符串变成任意相邻两个字母不同的,每次操作允许将 $B$ 字符串插入到 $A$ 字符串的任意位置,问是否有可能

思路

  • 首先,如果 $A$ 本来就是,那么就不用插入了
  • 其次,若 $B$ 本身不是,那肯定不行,毕竟最后插入的字符串一定是完整的,那么最终必然会不是
  • 然后,如果要插入,那必然是插入到两个相邻的字符内,那么必然 $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
36
37
38
39
40
41
42
43
44
45
void solve() {
int _;
cin >> _;
for (int ts = 0; ts < _; ++ts) {
int n, m;
cin >> n >> m;
string str1, str2;
str1.reserve(n);
str2.reserve(m);
cin >> str1 >> str2;

// check str 1
bool f[2] = {false, false};
for (int i = 1; i < n; ++i) if (str1[i] == str1[i - 1]) f[str1[i] - '0'] = true;
if (f[0] && f[1]) {
cout << "NO" << endl;
continue;
}

if (!f[0] && !f[1]) {
cout << "YES" << endl;
continue;
}

// check str 2
bool flag = true;
for (int i = 1; i < m; ++i) if (str2[i] == str2[i - 1]) flag = false;
if (!flag) {
cout << "NO" << endl;
continue;
}

if (f[str2[0] - '0']) {
cout << "NO" << endl;
continue;
}

if (f[str2[m - 1] - '0']) {
cout << "NO" << endl;
continue;
}

cout << "YES" << endl;
}
}

C. Qingshan Loves Strings 2

大致题意

有一个 $01$ 字符串,希望将这个字符串的中间对称位置字符不同,每次操作允许往任何位置插入一个 $01$ 字符串

思路

list 模拟一下就行了

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
void solve() {
int _;
cin >> _;
for (int ts = 0; ts < _; ++ts) {
int n;
cin >> n;
string str;
str.reserve(n);
cin >> str;

if (n % 2) {
cout << -1 << endl;
continue;
}

list<char> l;
for (auto &item : str) l.push_back(item);
int lp = 0, rp = n;
auto li = l.begin(), ri = l.end();
--ri;

bool flag = true;
vector<int> ans;
while (li != ri && lp < rp) {
if (*li != *ri) {
++li;
--ri;
++lp;
--rp;
continue;
}

if (*li == '0') {
ans.push_back(rp);
l.insert(++ri, '0');
l.insert(ri, '1');
--ri;
rp += 2;
} else if (*ri == '1') {
ans.push_back(lp);
l.insert(li, '1');
--li;
l.insert(li, '0');
--li;
rp += 2;
}

if (ans.size() > 300) {
flag = false;
break;
}
}

if (!flag) {
cout << -1 << endl;
} else {
cout << ans.size() << endl;
for (int i = 0; i < ans.size(); ++i) cout << ans[i] << " \n"[i == ans.size() - 1];
}
}
}

D. Doremy’s Connecting Plan

大致题意

有一个城市,每个城市都有一定的人数,现在希望在城市之间建立连接,如果满足 $\sum_{k \in S} a_k \geq i \times j \times c$,则可以建立链接,其中 $S$ 为节点 $i$ 和 $j$ 已经连通部分的所有节点集合

思路

考虑所有的节点按照一定顺序和 $1$ 城市建连

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, c;
cin >> n >> c;
vector<pair<int, int>> data(n);
for (auto&item: data) cin >> item.first;
for (int i = 0; i < n; ++i) data[i].second = i + 1;

int tot = data[0].first;

sort(data.begin(), data.end(), [&](const pair<int, int>&lhs, const pair<int, int>&rhs) {
return lhs.first - lhs.second * c > rhs.first - rhs.second * c;
});

bool flag = true;
for (auto&item: data) {
if (item.second == 1) continue;
if (tot + item.first >= item.second * c) tot += item.first;
else flag = false;
}

cout << (flag ? "YES" : "NO") << endl;
}
}

E1. Doremy’s Drying Plan (Easy Version)

大致题意

有一个城市,天气预报会预报未来 $m$ 天的下雨情况,允许选择其中两天不下雨,问最多可以有多少个城市这 $m$ 天不下雨

思路

根据起始和结束位置的下雨,标记数组,然后统计即可。因为只能选择两天,所以基本上是半暴力即可

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

void solve() {
int _;
cin >> _;
for (int ts = 0; ts < _; ++ts) {
int n, m, k;
cin >> n >> m >> k;
vector<vector<int>> start(n + 1), end(n + 1);
for (int i = 0; i < m; ++i) {
int u, v;
cin >> u >> v;
start[u].push_back(i);
end[v].push_back(i);
}

set<int> s;
map<pair<int, int>, int> ans1;
map<int, int> ans2;
int ans3 = 0;
for (int i = 1; i <= n; ++i) {
for (auto&item: start[i]) s.insert(item);

if (s.empty())
ans3++;
else if (s.size() == 1)
ans2[*s.begin()]++;
else if (s.size() == 2)
ans1[{*s.begin(), *s.rbegin()}]++;

for (auto&item: end[i]) s.erase(item);
}

int res = ans3;
for (auto&item: ans1) {
int tmp = item.second + ans3;
auto l = ans2.find(item.first.first), r = ans2.find(item.first.second);
if (l != ans2.end()) tmp += l->second;
if (r != ans2.end()) tmp += r->second;
res = max(res, tmp);
}

vector<int> ans2v;
ans2v.reserve(ans2.size());
for (auto&item: ans2) ans2v.push_back(item.second);
sort(ans2v.begin(), ans2v.end(), greater<>());
if (ans2v.size() == 1) res = max(res, ans2v[0] + ans3);
else if (ans2v.size() > 1) res = max(res, ans2v[0] + ans2v[1] + ans3);

cout << res << endl;
}
}