Codeforces 570D. Tree Requests
题目描述Roman 种植了一棵由 n 个顶点组成的树。每个顶点包含一个小写英文字母。顶点 1 是树的根,其余 n - 1 个顶点在树中都有一个 父顶点。顶点与其父顶点之间有一条边相连。顶点 i 的父顶点是顶点 pi ,父顶点的索引总是小于顶点的索引(即 pi < i )。
顶点的深度是指从根到 v 的路径上沿边的节点数。其中,根的深度等于 1 。
如果我们可以从顶点 u 到达父顶点 v ,那么我们说顶点 u 位于顶点 v 的子树中。其中,顶点 v 位于其子树中。
罗马给出了 m 个查询,其中第 i 个查询由两个数字 vi 、 hi 组成。让我们考虑位于深度 hi 的子树 vi 中的顶点。请判断能否用这些顶点上的字母组成一个 palindrome 字符串。写在顶点上的字母可以按任何顺序重新排列,以组成一个重码字符串,但应使用所有字母。
样例1234567896 51 1 1 3 3zacccd1 13 34 16 11 2
12345YesNoYesYesYes
启发式合并记录每一层节点的信息,判断是否可以组成回文串,检查的话很简单,维护一个cnt[N][26]统计每一层各个字母 ...
分布式锁
什么是分布式锁
Spring Boot 自动装配原理
Spring Boot 的自动装配是在他的核心注解 @SpringBootApplication 实现的,@SpringBootApplication 大概可以看成@Configuration、@EnableAutoConfiguration、@ComponentScan 注解的集合。其中@EnableAutoConfiguration 就算启用 Spring Boot 的自动装配机制,@EnableAutoConfiguration 通过 @Import 导入了 AutoConfigurationImportSelector 这个类,AutoConfigurationImportSelector 类中的 getCandidateConfiguration 方法会将所有自动配置类的信息以 List 的形式返回,并交由 Spring 容器做 bean 来管理。最后,通过@Conditional等条件注解按需加载的配置类,其他的将被过滤掉。
参考 SpringBoot 的启动过程:
当启动 Spring Boot 应用程序的时候,会先创建 SpringApplication 的对象,在对象 ...
做题记录Atcoder-Beginner-Contest-328
A Not Too Hard1234567891011121314151617181920212223242526272829303132#include<bits/stdc++.h>using namespace std;#define int long longint read(){ int x = 0, f = 1; char ch = getchar(); while(ch < '0' || ch > '9') { if(ch == '-') f = -1; ch = getchar(); } while(ch >= '0' && ch <= '9') { x= x * 10 + ch - '0'; ch = getchar(); } return x * f;}signed main(){ int n = read(), x = ...
做题记录 Atcoder-Beginner-Contest-143
A - Curtain翻译练习高桥的房间的窗户宽A,有两个窗帘悬挂在窗户上,每一个窗帘水平长度为B(竖直方向足够长可以覆盖整个窗户),我们将关闭窗户,以尽量减少窗帘未遮挡部分的总水平长度。求窗户无遮挡部分的水平总长度。
12345678910111213141516171819202122232425#include<bits/stdc++.h>using namespace std;#define int long longint read(){ int x = 0, f = 1; char ch = getchar(); while(ch < '0' || ch > '9') { if(ch == '-') f = -1; ch = getchar(); } while(ch >= '0' && ch <= '9') { x= x * 10 + ch - '0'; ...
ABC142
你是抱着多大的觉悟说出这种话的🙄️你只不过是一个学生,有办法背负其他人的人生吗😡“什么都愿意做”就是这么沉重的话😡做不来的事就别轻易说出口😡你这个人,满脑子都只想到自己呢😒
Aeasy
12345678910111213141516171819202122232425262728293031#include<bits/stdc++.h>using namespace std;#define int long longint read(){ int x = 0, f = 1; char ch = getchar(); while(ch < '0' || ch > '9') { if(ch == '-') f = -1; ch = getchar(); } while(ch >= '0' && ch <= '9') { x= x * 10 + ch - '0'; ...
ABC139
A - Tenki模拟
123456789101112131415#include <bits/stdc++.h>using namespace std;int main(int argc, char const *argv[]){ ios::sync_with_stdio(0);cin.tie(0);cout.tie(0); string s, t; cin >> s >> t; int res = 0; for(int i = 0; i < 3; i++) if(s[i] == t[i]) res++; cout << res << endl; return 0;}
B - Power Socket模拟
12345678910111213141516171819#include <bits/stdc++.h>using namespace std;int main(int argc, char const *argv[]){ ...
ABC138
A. Red or Not模拟
123456789101112131415#include <bits/stdc++.h>using namespace std;int main(int argc, char const *argv[]){ ios::sync_with_stdio(0);cin.tie(0);cout.tie(0); int a; string s; cin >> a >> s; if(a >= 3200) cout << s << endl; else cout << "red" << endl; return 0;}
B. Resistors in Parallel模拟
123456789101112131415161718#include <bits/stdc++.h>using namespace std;int main(int argc, char const *argv[] ...
计算机网络
计算机网络体系结构计算机网络的定义一些相互连接的、自治的计算机的集合,互连是指计算机之间可以通过有线或者无线的方式进行数据通信,自治是指独立的计算机,它有自己的软硬件,集合是指至少两台计算机
计算机网络分类按覆盖范围分类局域网LAN一般用微型计算机或者工作站通过高速线路相连
城域网MAN如其名,覆盖一座城市
广域网WAN长距离通信,覆盖国家地区,因特网的核心部分,任务是互连分布在不同区域的城域网和局域网
按使用者分类公用网电信公司出资建造的网络,交钱能用
专用网某个部门为了特殊业务需要而建造的网络,如军用网
传输技术分类广播式网络所用联网的计算机共享一个公共通信信道
点对点网络每个物理线路连接一对计算机
按拓扑结构分类总线型、星型、环形网络,网状网络
按交换技术分类见后文
按传输介质分类有线网络,无线网络
计算机网络的性能指标速率: bit/s带宽: 通信线路的最大传输速率 bit/s吞吐量: 单位时间内某个网络的数据量时延: 数据从一段发送到另一端所需要的时间,发送时延,传播时延,处理时延,排队时延时延带宽积: 发送端第一个bit到达终点时,发送端已经发送的bit ...
ABC134
今天六点起的,好困,F没写,想睡觉,醒了一定补
A123456789101112131415161718192021222324252627#include<bits/stdc++.h>using namespace std;#define int long longint read(){ int x = 0, f = 1; char ch = getchar(); while(ch < '0' || ch > '9') { if(ch == '-') f = -1; ch = getchar(); } while(ch >= '0' && ch <= '9') { x = x * 10 + ch - '0'; ch = getchar(); } retur ...