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

推荐订阅源

Know Your Adversary
Know Your Adversary
D
Docker
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
人人都是产品经理
人人都是产品经理
V
V2EX
V
Visual Studio Blog
J
Java Code Geeks
博客园 - 【当耐特】
罗磊的独立博客
量子位
W
WeLiveSecurity
博客园 - 聂微东
Hugging Face - Blog
Hugging Face - Blog
The Cloudflare Blog
O
OpenAI News
PCI Perspectives
PCI Perspectives
The Last Watchdog
The Last Watchdog
S
Schneier on Security
博客园 - Franky
WordPress大学
WordPress大学
T
Tor Project blog
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
D
Darknet – Hacking Tools, Hacker News & Cyber Security
Recent Commits to openclaw:main
Recent Commits to openclaw:main
Security Latest
Security Latest
Cisco Talos Blog
Cisco Talos Blog
腾讯CDC
美团技术团队
博客园 - 叶小钗
www.infosecurity-magazine.com
www.infosecurity-magazine.com
月光博客
月光博客
S
Secure Thoughts
Engineering at Meta
Engineering at Meta
T
Tailwind CSS Blog
TaoSecurity Blog
TaoSecurity Blog
Google DeepMind News
Google DeepMind News
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
Last Week in AI
Last Week in AI
aimingoo的专栏
aimingoo的专栏
G
Google Developers Blog
D
DataBreaches.Net
Project Zero
Project Zero
S
SegmentFault 最新的问题
C
Cisco Blogs
H
Help Net Security
Google Online Security Blog
Google Online Security Blog
A
About on SuperTechFans
F
Fortinet All Blogs
博客园 - 司徒正美

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 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 914 (Div. 2)
Shiroha · 2024-02-15 · via Shiroha白羽的博客

A. Forked!

大致题意

棋盘上有一个皇后和一个国王,且骑士的移动方式是给出的 “日” 字形式,存在几个位置,使得骑士可以同时吃国王和皇后

思路

虽然不是 “日” 字,但是一个骑士最多也就只能走 8 个位置,所以暴力枚举就行

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
void solve() {
int _;
cin >> _;
for (int tc = 0; tc < _; ++tc) {
int a, b, xk, yk, xq, yq;
cin >> a >> b >> xk >> yk >> xq >> yq;
const int arr[4][2] = {1, 1, 1, -1, -1, 1, -1, -1};
set<pair<int, int>> s;
for (const auto ar: arr) {
s.insert({xk + a * ar[0], yk + b * ar[1]});
s.insert({xk + b * ar[0], yk + a * ar[1]});
}

int ans = 0;
for (const auto ar: arr) {
if (s.count({xq + a * ar[0], yq + b * ar[1]})) {
s.erase({xq + a * ar[0], yq + b * ar[1]});
++ans;
}
if (s.count({xq + b * ar[0], yq + a * ar[1]})) {
s.erase({xq + b * ar[0], yq + a * ar[1]});
++ans;
}
}

cout << ans << endl;
}
}

B. Collecting Game

大致题意

有一个数组,选择其中的一个值作为初始值,然后每次进行如下操作:

  1. 选择一个剩下的值,满足其小于当前的值
  2. 删除它,并把其值加到当前值上

问每一位的值作为初始值的情况下,最多可以干掉多少值

思路

因为每一个值都可以干掉它以及比它小的值,所以只需要这些值加起来比恰好大于它的值还要大的话,那么就可以继续增大

而最终的结果一定是卡在某个值处,使得所有逼比它小的值加起来都没有它大,那么这个时候,比它小的那个值必然只能消除到这个位置

依次类推,只需要依次找到满足 $\sum_{i=1}^x a_i < a_{x+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 tc = 0; tc < _; ++tc) {
int n;
cin >> n;
vector<pair<int, int>> data(n);
for (auto& [fst, snd]: data) cin >> fst;
for (int i = 0; i < n; ++i) data[i].second = i;
sort(data.begin(), data.end());
vector<int> ans(n);
int l = 0, sum = 0;
while (l < n) {
int r = l + 1;
sum += data[l].first;
while (r < n && sum >= data[r].first) {
sum += data[r].first;
++r;
}
for (int i = l; i < r; ++i) ans[data[i].second] = r - 1;

l = r;
}
for (int i = 0; i < n; ++i) cout << ans[i] << " \n"[i == n - 1];
}
}

C. Array Game

大致题意

有一个数组,允许你每次选择其中的两个值,把它们的差值加入到队列中,问经过 $k$ 次操作后,数组中最小的值最小可能是多少

思路

如果操作三次,那么可以连续两次拿同两个值,然后再让结果的那两值的差值加入数组,那么必然得到 $0$,即最小的值

所以问题只需要考虑一次操作和两次操作即可

一次操作很简单,$n^2$ 暴力扫就行了

二次操作也很简单,$n^2$ 暴力扫的同时,将结果和原始数组中看看,是否有足够相近的值

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

void solve() {
int _;
cin >> _;
for (int tc = 0; tc < _; ++tc) {
int n, k;
cin >> n >> k;
set<int> s;
vector<int> data(n);
for (int i = 0; i < n; ++i) {
int tmp;
cin >> tmp;
data[i] = tmp;
s.insert(tmp);
}
if (k >= 3) {
cout << 0 << endl;
continue;
}
if (k == 0) {
cout << *s.begin() << endl;
continue;
}
int ans1 = *s.begin(), ans2 = *s.begin();
for (int i = 0; i < n; ++i) {
for (int j = i + 1; j < n; ++j) {
int tmp = abs(data[i] - data[j]);
auto riter = s.upper_bound(tmp);
auto liter = riter;
if (liter != s.begin()) --liter;
if (riter == s.end()) --riter;
ans1 = min(ans1, tmp);
ans2 = min(min(ans2, tmp), min(abs(*riter - tmp), abs(*liter - tmp)));
}
}
if (k == 1) cout << ans1 << endl;
else cout << ans2 << endl;
}
}

D2. Set To Max (Hard Version)

大致题意

有一个数组,允许每次操作选择一个区间 $[l, r]$,使得 $a_i \leftarrow max(a_{l \dots r}), \forall i \in [l, r]$

问只操作数组 $a$ 的情况下是否有可能做到

思路

首先,数组 $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
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
void solve() {
int _;
cin >> _;
for (int tc = 0; tc < _; ++tc) {
int n;
cin >> n;
vector<int> a(n), b(n), la(n, 0), ra(n, n);
int r = n - 1;
for (auto& i: a) cin >> i;
for (auto& i: b) cin >> i;
stack<int> st;
for (int i = 0; i < n; ++i) {
while (!st.empty() && a[st.top()] < a[i]) {
ra[st.top()] = i;
st.pop();
}
st.push(i);
}
while (!st.empty()) st.pop();

for (int i = n - 1; i >= 0; --i) {
while (!st.empty() && a[st.top()] < a[i]) {
la[st.top()] = i + 1;
st.pop();
}
st.push(i);
}
while (!st.empty()) st.pop();

bool flag = true;
for (int i = n - 1; i >= 0; --i) {
while (r >= 0 && (a[r] != b[i] || la[r] > i || ra[r] <= i)) --r;
if (a[r] != b[i] || la[r] > i || ra[r] <= i) {
flag = false;
break;
}
}

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