atcoder 162c game tree

AtCoder Grand Contest 056 D Subset Sum Game

洛谷传送门 AtCoder 传送门 考虑若 \(n\) 是奇数怎么做。枚举 Alice 第一次选的数 \(a_i\),然后考虑把剩下的数两两结成一个匹配,若 Bob 选了其中一个,Alice 就选另一个。容易发现排序后奇数位和它右边的偶数位匹配最优。那么设奇数位的和为 \(A\),偶数位的和为 \( ......
AtCoder Contest Subset Grand Game

AtCoder Beginner Contest 178 E

AtCoder Beginner Contest 178 E E - Dist Max 曼哈顿距离最大点对 \(ans = max(|x_i-x_j|+|y_i-y_j|)\) 考虑去绝对值,4种情况。sort一下取max即可。 #include <bits/stdc++.h> using name ......
Beginner AtCoder Contest 178

AtCoder Beginner Contest 322

A - First ABC 2 解题思路 签到 Code #include <bits/stdc++.h> using namespace std; typedef long long LL; void solve() { int n; cin >> n; string s; cin >> s; i ......
Beginner AtCoder Contest 322

CF1873F Money Trees

思路 要求最长长度,想到可以二分答案。 那么现在需要考虑如何快速验证答案是否正确。 可以 \(O(n)\) 枚举区间左端点,因为有了长度,所以可以直接获得右端点的值,直接验证右端点是否合法。 因为要求区间的每个数都是右边的数的倍数,所以可以提前预处理每个点最远的满足这个条件的右端点,直接判断合不合法 ......
1873F Money Trees 1873 CF

CF1875B Jellyfish and Game

思路 题意大概是两人都有一组数,奇数轮,第一个人可以选择和第二个人交换一个数字也可以不换,偶数轮,第二个人可以选择和第一个人交换一个数字也可以不换。 首先可以猜测,我们每次都应该选择交换对方的最大值和自己的最小值,如果自己的最小值都比对方大的话就不交换。应该比较好想,这里感性证明一下。 如果用的不是 ......
Jellyfish 1875B 1875 Game and

[AtCoder] E - Packing Under Range Regulations

Key idea: For a given box and a list of balls that can be placed in this box, we should choose the ball with the smallest R. Proof: say we have box B ......
Regulations AtCoder Packing Under Range

AtCoder Beginner Contest 322

A - First ABC 2 (abc322 A) 题目大意 给定一个字符串,找到最先出现ABC的位置。 解题思路 直接查找判断即可。 神奇的代码 #include <bits/stdc++.h> using namespace std; using LL = long long; int mai ......
Beginner AtCoder Contest 322

UTPC 2021 L Maze Game

洛谷传送门 AtCoder 传送门 若图中存在点使得删去它后 \(S, T\) 不连通,那么 A 可以一步获胜。 否则,双方都不会删去一个点使得删去它后会产生一个点使得删去它后 \(S, T\) 不连通。那么到最后图上会剩下两条 \(S \to T\) 的不交路径。此时一方无论如何操作都会使得另一方 ......
UTPC 2021 Maze Game

在主板为TUF GAMING B550M-PLUS WIFI II的电脑上安装操作系统window10,主板上的蓝牙和wifi无法启动问题的解决方案。

去华硕官网,下载相关驱动,并安装即可。 本人从网站https://www.asus.com.cn/motherboards-components/motherboards/tuf-gaming/tuf-gaming-b550m-plus-wifi-ii/helpdesk_download/?mode ......
主板 解决方案 方案 GAMING M-PLUS

[题解] CF1003E - Tree Constructing

CF1003E - Tree Constructing 题目传送门 知识点:贪心 题意 给定 \(n\) 个顶点,问是否能够构造出一棵直径为 \(d\) 的树,且每个顶点的度数最多为 \(k\) 。 思路 我们要构造出一棵树,使得其直径长度一定为 \(d\) ,那么我们可以先选择 \(d + 1\) ......
题解 Constructing 1003E 1003 Tree

创建一个二叉排序树(Binary Search Tree)

一、二叉排序树的定义 左子树所有结点的值均小于根结点的值 右子树所有结点的值均大于根节点的值 左子树和右子树也是二叉排序树 1.二叉排序树的结点结构 typedef struct BSTNode { /*二叉排序树的结点结构*/ int value; struct BSTNode *left; st ......
Binary Search Tree

GAMES202作业5

目录作业要求单帧降噪联合双边滤波累加上一帧对时间的滤波Temporalmotion vector计算当前像素在上一帧的对应点计算累加后的颜色用A-Trous Wavelet加速单帧降噪 作业要求 本次作业,我们需要实现一个简单的实时光线追踪的降噪方法。光线追踪的渲染结果,G-Buffer 及其他相关 ......
GAMES 202

G. wxhtzdy ORO Tree

G. wxhtzdy ORO Tree 前提知识:lca求最近公共祖先(倍增) 因为或运算越多值就越大,好像跟上一个相反,所以满足单调不降 要点1:利用数组来对每个点到其祖先节点的或和进行计算(倍增) 要点2:分别对左右两边进行分析到lca点,这样确保无误 要点3:因为满足单调不降,所以遇到大于的节 ......
wxhtzdy Tree ORO

加训日记 Day3——atcoder ABC321乐子场

Day3,9.23 ·打了场acwing周赛,第三题差点就想出来了,想歪到组合数上乱选了呜呜呜 ·ABC321场写的太抽象了,A题上来wa两次,B题少考虑情况乱wa ·C题更是重量级,想不出来正确做法直接暴力,结果打表最后少写了几个数,纯纯犯病场 ·最后加了36分没绷住 acwing周赛排名 atc ......
乐子 atcoder 日记 Day3 Day

AtCoder Regular Contest 123 F Insert Addition

洛谷传送门 AtCoder 传送门 用 \((x, y)\) 表示 \(Ax + By\),那么这个等价于 SB 树。 那么直接在 SB 树上二分,遍历一遍找到 \(n\) 个点就好了。可以采用类似线段树查询的方式。 于是现在还剩下一个子问题:给定 \(a, b\),求 \(ax + by \le ......
Addition AtCoder Regular Contest Insert

qoj6735. Tree (The 1st Universal Cup. Stage 22: Shaanxi)

https://qoj.ac/contest/1287/problem/6735 考虑定一个根,然后把每个点的点权附属在父边权上,让每条边的边权变成一个 pair。 这样,一个符合条件的路径需要满足的条件是:路径内所有边的边权 pair 相同,以及 路径根节点(lca)的颜色符合。 对于当前树上每个 ......
Universal Shaanxi Stage 6735 Tree

AtCoder Regular Contest 127 F ±AB

洛谷传送门 AtCoder 传送门 非常妙的题。 先直观感受一下,显然当 \(M\) 大到一定程度后,\([0, M]\) 的所有数都能被取到。考虑 \(V \gets V + Ax + By\),其中 \(V + Ax + By \in [0, M]\)。如果 \(x, y\) 都是正数显然可以取 ......
AtCoder Regular Contest 127 177

[题解] CF1882D - Tree XOR

CF1882D - Tree XOR 知识点:换根 DP 。 主要难点是要思考如何操作使得代价最小,这个过程是一个贪心的过程。想到怎么操作,计算答案的过程就是一个板子换根了。 题意 给定一颗 \(n\) 个节点的树,点 \(i\) 具有权值 \(a_i\) 。现在需要你不断执行以下操作,使得树上所有 ......
题解 1882D 1882 Tree XOR

根据一个数组,创建一个Segment Tree(线段树)

线段树的特点 线段树的优势 线段树的构造过程 线段树的基本数据结构(结点结构由五个分量组成) 运行结果 (C语言代码)递归的创建一颗线段树,然后中序、先序、后序遍历这个结点 #include <stdio.h> #include <stdlib.h> #include <stdbool.h> typ ......
线段 数组 Segment Tree

Atcoder ABC321 笔记

A - 321-like Checker \(\color{gray}{22}\) 直接模拟 void solve() { int n; cin >> n; int lst = -1; for(int i = n; i; i /= 10) { int u = i % 10; if(u <= lst) ......
Atcoder 笔记 ABC 321

AtCoder Regular Contest 102

C - Triangular Relationship 枚举 \(a\bmod k\) 的值,\(b\bmod k,c\bmod k\) 的值也就确定了,算下贡献就好了。 #include<iostream> #include<cstdio> using namespace std; int n,k ......
AtCoder Regular Contest 102

AtCoder Regular Contest 103

C - //// 如果奇数和偶数出现的颜色的最大值相同一边取最大值和一边取次大值,否则两边都选最大值即可。 #include<iostream> #include<cstdio> #include<algorithm> using namespace std; const int N=100005; ......
AtCoder Regular Contest 103

AtCoder Grand Contest 028

A - Two Abbreviations 答案要么就是 \(\operatorname{lcm}(n,m)\) 要么就是 \(-1\)。判断下 \(\operatorname{lcm}(n,m)\) 是否合法就是了。 #include<iostream> #include<cstdio> usin ......
AtCoder Contest Grand 028

AtCoder Grand Contest 027

A - Candy Distribution Again 从小到大贪心,可以发现一定是满足一个前缀,暴力判断就行了。 #include<iostream> #include<cstdio> #include<algorithm> using namespace std; const int N=10 ......
AtCoder Contest Grand 027

AtCoder Grand Contest 026

A - Colorful Slimes 2 可以发现,对于连续的一段长度为 \(m\) 的相同的字符,我们可以花费 \(\lfloor \frac{m}{2}\rfloor\) 的代价将它改为符合要求的。 #include<iostream> #include<cstdio> using names ......
AtCoder Contest Grand 026

AtCoder Grand Contest 025

A - Digits Sum 按题意模拟即可。 #include<iostream> #include<cstdio> using namespace std; const int INF=1061109567; int n; int calc(int x) { int res=0; while(x ......
AtCoder Contest Grand 025

AtCoder Grand Contest 024

A - Fairness 每次操作后 \(a_i-b_i=b_{i-1}-a_{i-1}\),对 \(k\) 的奇偶性讨论一下即可。 #include<iostream> #include<cstdio> using namespace std; int a,b,c; long long k; in ......
AtCoder Contest Grand 024

AtCoder Grand Contest 023

A - Zero-Sum Ranges 令 \(s_n=\sum\limits_{i=1}^n a_i\),相当于找满足 \(l\le r,s_r-s_{l-1}\) 的点对 \((l,r)\) 的个数,直接搞就完事了。 #include<iostream> #include<cstdio> #in ......
AtCoder Contest Grand 023

AtCoder Grand Contest 022

A - Diverse Word 如果至少有一个字符没有出现过,只要在原字符串后面加入一个没有出现过的字符中最小的那个字符就好了。 如果所有字符都出现过,找到一个尽量靠后的位置 \(i\in [1,n)\),使得 \(s_i\lt s_{i+1}\),最优字符串将 \(s_i\) 换成 \([i+1 ......
AtCoder Contest Grand 022

AtCoder Grand Contest 021

A - Digit Sum 2 要么是 \(n\) 要么是 \(n\) 的第一位后面加上若干个 \(9\)。 #include<iostream> #include<cstdio> #include<cmath> using namespace std; long long n; int calc( ......
AtCoder Contest Grand 021