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

推荐订阅源

Google DeepMind News
Google DeepMind News
www.infosecurity-magazine.com
www.infosecurity-magazine.com
L
LINUX DO - 最新话题
N
News | PayPal Newsroom
S
Security Affairs
W
WeLiveSecurity
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
Webroot Blog
Webroot Blog
Spread Privacy
Spread Privacy
A
Arctic Wolf
T
Troy Hunt's Blog
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
D
Darknet – Hacking Tools, Hacker News & Cyber Security
C
Cybersecurity and Infrastructure Security Agency CISA
T
Threat Research - Cisco Blogs
V2EX - 技术
V2EX - 技术
Scott Helme
Scott Helme
Google Online Security Blog
Google Online Security Blog
Schneier on Security
Schneier on Security
F
Fortinet All Blogs
U
Unit 42
爱范儿
爱范儿
腾讯CDC
S
Security @ Cisco Blogs
PCI Perspectives
PCI Perspectives
Hacker News - Newest:
Hacker News - Newest: "LLM"
Apple Machine Learning Research
Apple Machine Learning Research
C
CERT Recently Published Vulnerability Notes
Security Latest
Security Latest
Y
Y Combinator Blog
S
Schneier on Security
Cisco Talos Blog
Cisco Talos Blog
T
The Blog of Author Tim Ferriss
Hugging Face - Blog
Hugging Face - Blog
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
IT之家
IT之家
K
Kaspersky official blog
Security Archives - TechRepublic
Security Archives - TechRepublic
博客园 - 聂微东
Cloudbric
Cloudbric
V
V2EX
H
Help Net Security
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
小众软件
小众软件
TaoSecurity Blog
TaoSecurity Blog
T
Tor Project blog
G
Google Developers Blog
人人都是产品经理
人人都是产品经理
GbyAI
GbyAI
MyScale Blog
MyScale Blog

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) 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
Pinely Round 3 (Div. 1 + Div. 2)
Shiroha · 2024-02-24 · via Shiroha白羽的博客

A. Distinct Buttons

大致题意

初始在 $(0, 0)$ 点,问是否可能只往三个方向移动的情况下,到达所有给出的点位,不需要按照顺序

思路

看看所有点是不是都在两个相邻的象限内即可

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;
bool flag[4] = {true, true, true, true};
for (int i = 0; i < n; ++i) {
int u, v;
cin >> u >> v;
if (u > 0) flag[0] = false;
if (u < 0) flag[1] = false;
if (v > 0) flag[2] = false;
if (v < 0) flag[3] = false;
}
cout << (flag[0] || flag[1] || flag[2] || flag[3] ? "YES" : "NO") << endl;
}
}

B. Make Almost Equal With Mod

大致题意

有一个数组,允许你挑选一个值,让所有值 mod 它之后,剩下的值中至少有两个不一样的,问可能的选择

思路

从二进制角度看,找到最后一位大家都不一样的,然后取比它大一点的那个 $2^n$ 即可

AC code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#define int long long

void solve() {
int _;
cin >> _;
for (int tc = 0; tc < _; ++tc) {
int n;
cin >> n;
vector<int> data(n);
for (auto& i: data) cin >> i;
int k = 2;
while (true) {
set<int> tmp;
for (int i = 0; i < n; ++i) tmp.insert(data[i] % k);
if (tmp.size() > 1) {
cout << k << endl;
break;
}
k <<= 1;
}
}
}

C. Heavy Intervals

大致题意

有一堆区间$[l_i, r_i]$和相同数量的以及数组 $c$,问是否可以通过重新排列每个区间的 $l$, $r$ 以及 $c$,使得

$\sum_{i=1}^n c_i \times (r_i - l_i)$ 最小

思路

可以得到,要让最大的 $c$ 去匹配最小的区间即可,所以要尽可能制造 $(r_i - l_i)$ 之和不变的情况下,区间差异最大

所以可以从大到小遍历 $r$ 去找对应第一个匹配的 $l$ 即可

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

void solve() {
int _;
cin >> _;
for (int tc = 0; tc < _; ++tc) {
int n;
cin >> n;
vector<int> l(n), c(n);
map<int, int> r;
for (auto& i: l) cin >> i;
for (int i = 0; i < n; ++i) {
int tmp;
cin >> tmp;
++r[tmp];
}
for (auto& i: c) cin >> i;
sort(l.begin(), l.end(), greater<>());
sort(c.begin(), c.end());
vector<int> len(n);
for (int i = 0; i < n; ++i) {
const auto iter = r.upper_bound(l[i]);
len[i] = iter->first - l[i];
if (iter->second == 1) r.erase(iter);
else --iter->second;
}
sort(len.begin(), len.end());
int ans = 0;
for (int i = 0; i < n; ++i) ans += len[i] * c[n - 1 - i];
cout << ans << endl;
}
}

D. Split Plus K

大致题意

有一个初始的数组,允许每次选择其中的一个值,让其加上给出的 $k$,然后拆成两个,

问经过多少次操作后,整个数组的所有值相同

思路

假设最终的值为 $m$,可以得到

$a_i = m \times t_i - (t_i - 1) \times k$

化简得到 $a_i - k = t_i \times (m - k)$

由于都是整数,且所有 $i$ 的 $m - k$ 相同,则可以得到 $m - k$ 可以是 $gcd_{i=1}^n (a_i - k)$

那么就简单了

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

// NOLINTNEXTLINE(*-no-recursion)
auto gcd(const int a, const int b) -> int {
if (b == 0) return a;
return gcd(b, a % b);
}

void solve() {
int _;
cin >> _;
for (int tc = 0; tc < _; ++tc) {
int n, k;
cin >> n >> k;
vector<int> data(n);
for (auto& i: data) cin >> i;

if (n == 1) {
cout << 0 << endl;
continue;
}
int mk = data[0] - k;
for (int i = 1; i < n; ++i) mk = gcd(mk, data[i] - k);
if (mk == 0) {
cout << 0 << endl;
continue;
}

int ans = LONG_LONG_MAX;
auto check = [&](int m) {
if (m == k) return false;
bool flag = true;
int tmp = 0;
for (int i = 0; i < n; ++i) {
if ((data[i] - m) % (m - k) != 0 || (data[i] - m) / (m - k) < 0) {
flag = false;
break;
}
tmp += (data[i] - m) / (m - k);
}
if (flag) ans = min(ans, tmp);
return flag;
};

check(mk + k);
cout << (ans == LONG_LONG_MAX ? -1 : ans) << endl;
}
}