Educational Round 64 题解
前言:
这场太难了……我一个紫名只打出两题……(虽说感觉的确发挥不够好)
一群蓝绿名的dalao好像只打了两题都能升分的样子……
庆幸的是最后A出锅然后unr了>///<
写一波题解纪念这次失败的edu吧。
A
看起来很像sb题……实则细节巨多……
一开始分了六类就过了……
然后重测一遍就挂了……所以出题人做错自己出的题了?
注意特判三角形在圆里又在一个正方形的情况,会少一个点。
B
一开始想的是把相同的字母压一起,然后按ace...ybdf...z这样排。
然而出现一些毒瘤还是不行,然后就一直在想调换首位什么的,一直挂一直挂……
最后还是zz先切了……在奇数中选一个,偶数中选一个,它们不相邻,然后奇序列和偶序列之间插入这两个,就不会有这种问题了。
C
一眼贪心,一发WA。这么简单的正解没想到……
二分,每次把 $i(1\le i\le mid)$ 和 $n-mid+i$ 匹配看看行不行。
D
看起来是个树形dp,$f[u][0/1/2/3]$ 表示从下往上到 $u$ 分别是全 $0$,全 $1$,先 $0$ 再 $1$,先 $1$ 再 $0$ 的路有多少。
赛场上想出了然而打炸了……赛后又调出来了……。
具体转移看代码吧,应该能看懂的。
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> PII;
const int maxn=;
#define MP make_pair
#define PB push_back
#define lson o<<1,l,mid
#define rson o<<1|1,mid+1,r
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define ROF(i,a,b) for(int i=(a);i>=(b);i--)
#define MEM(x,v) memset(x,v,sizeof(x))
inline ll read(){
char ch=getchar();ll x=,f=;
while(ch<'' || ch>'') f|=ch=='-',ch=getchar();
while(ch>='' && ch<='') x=x*+ch-'',ch=getchar();
return f?-x:x;
}
int n,el,head[maxn],to[maxn],w[maxn],nxt[maxn];
ll f[maxn][],ans;
inline void add(int a,int b,int c){
to[++el]=b;nxt[el]=head[a];head[a]=el;w[el]=c;
}
void dfs(int u,int F){
ll s=;
for(int i=head[u];i;i=nxt[i]){
int v=to[i];
if(v==F) continue;
dfs(v,u);
if(w[i]){
s+=f[u][]*(f[v][]+);
s+=f[u][]*(f[v][]+*f[v][]+f[v][]+);
s+=f[u][]*(f[v][]+);
s+=f[v][]+*f[v][]+f[v][]+;
f[u][]+=f[v][]+;
f[u][]+=f[v][]+f[v][];
}
else{
s+=f[u][]*(*f[v][]+f[v][]+f[v][]+);
s+=f[u][]*(f[v][]+);
s+=f[u][]*(f[v][]+);
s+=*f[v][]+f[v][]+f[v][]+;
f[u][]+=f[v][]+;
f[u][]+=f[v][]+f[v][];
}
}
ans+=s;
}
int main(){
n=read();
FOR(i,,n-){
int u=read(),v=read(),w=read();
add(u,v,w);add(v,u,w);
}
dfs(,);
cout<<ans;
}
后面的,以后会做了再说吧……
Educational Round 64 题解的更多相关文章
- Codeforces Educational Round 33 题解
题目链接 Codeforces Educational Round 33 Problem A 按照题目模拟,中间发现不对就直接输出NO. #include <bits/stdc++.h> ...
- Educational Round 66 题解
作为橙名来水了一发…… 这次题目就比上次良心多了.7题有5题会做. 然而风格仍然很怪异……还是练少了? A 水题.不过一开始没注意细节挂了几发,罚时罚的真痛…… 明显是能除以 $k$ 就除以 $k$, ...
- Educational Codeforces Round 64 (Rated for Div. 2)题解
Educational Codeforces Round 64 (Rated for Div. 2)题解 题目链接 A. Inscribed Figures 水题,但是坑了很多人.需要注意以下就是正方 ...
- Educational Codeforces Round 64 部分题解
Educational Codeforces Round 64 部分题解 不更了不更了 CF1156D 0-1-Tree 有一棵树,边权都是0或1.定义点对\(x,y(x\neq y)\)合法当且仅当 ...
- Educational Codeforces Round 64部分题解
Educational Codeforces Round 64部分题解 A 题目大意:给定三角形(高等于低的等腰),正方形,圆,在满足其高,边长,半径最大(保证在上一个图形的内部)的前提下. 判断交点 ...
- Educational Codeforces Round 64(ECR64)
Educational Codeforces Round 64 CodeForces 1156A 题意:1代表圆,2代表正三角形,3代表正方形.给一个只含1,2,3的数列a,ai+1内接在ai内,求总 ...
- CF Educational Round 78 (Div2)题解报告A~E
CF Educational Round 78 (Div2)题解报告A~E A:Two Rival Students 依题意模拟即可 #include<bits/stdc++.h> us ...
- [Educational Round 5][Codeforces 616F. Expensive Strings]
这题调得我心疲力竭...Educational Round 5就过一段时间再发了_(:з」∠)_ 先后找了三份AC代码对拍,结果有两份都会在某些数据上出点问题...这场的数据有点水啊_(:з」∠)_[ ...
- [Educational Round 3][Codeforces 609E. Minimum spanning tree for each edge]
这题本来是想放在educational round 3的题解里的,但觉得很有意思就单独拿出来写了 题目链接:609E - Minimum spanning tree for each edge 题目大 ...
随机推荐
- POJ 2249 暴力求组合数
Binomial Showdown Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 22692 Accepted: 692 ...
- 使用 Spring Boot 构建 RESTful API
1. 使用 Idea 创建 Spring Initializer 项目 在创建项目的对话框中添加 Web 和 Lombok,或者建立项目后在 pom.xml 中添加依赖: <dependency ...
- Prometheus监控学习笔记之Prometheus 2.x版本的常用变化
最近用了prometheus 2.0 版本,感觉改变还是有点大,现将改变相关记录如下: 1.prometheus.yml文件配置修改后,要想重新加载,必须在启动的时候添加参数: --web.enabl ...
- C# LDAP认证登录类参考
public class LDAPHelper { private DirectoryEntry _objDirectoryEntry; /// <sum ...
- Linq分批次,每组1000条
/// <summary> /// 分组插入每次插入1000 /// </summary> /// <param name="data">< ...
- ActionMq + mqttws3.1 实现持久化订阅
activemq版本:5.15.3 Eclipse Paho MQTT JavaScript library mqttws3.1:在amq安装目录下webapp-demo目录下可以找到 实现步骤请阅读 ...
- 使用linq对ado.net查询出来dataset集合转换成对象(查询出来的数据结构为一对多)
public async Task<IEnumerable<QuestionAllInfo>> GetAllQuestionByTypeIdAsync(int id) { st ...
- EF 通过导航添加数据
Fluent Api是指定模型与数据库表之间的对应关系 //一对多 this.HasOptional(x => x.主表).WithMany(x => x.多表).HasForeignKe ...
- Postgresql中无则插入的使用方法INSERT INTO WHERE NOT EXISTS
一.问题 Postgresql中无则插入的使用方法INSERT INTO WHERE NOT EXISTS,用法请参考样例. 二.解决方案 (1)PostgresSQL INSERT INTO tes ...
- Git remote: ERROR: missing Change-Id in commit message
D:\code\项目仓库目录>git push origin HEAD:refs/for/dev/wangteng/XXXXX key_load_public: invalid format E ...