题意:n个点,n-1条边,组成一个无向的联通图,然后给出q和k,q次询问,每次给出两个点,问这两个点之间的最短距离但必须经过k点. 思路:我当时是用优化的Dijkstra写的(当天刚学的),求出k点到各点的最短距离,跑了160+ms,其实用搜索写更快,组里的几个大佬都用搜索写的,我在搜索这方面还是比较弱的.还要多练练.然后今天早上用搜索写了一下,跑了60+ms,并且内存用的也很小. 题目链接:http://abc070.contest.atcoder.jp/tasks/abc070_d Dijk…
题目链接:http://abc070.contest.atcoder.jp/assignments A - Palindromic Number Time limit : 2sec / Memory limit : 256MB Score : 100 points Problem Statement You are given a three-digit positive integer N.Determine whether N is a palindromic number.Here, a…
我好想有点思维江化,所以我想给这个丝毫没有问题的abc也写下 A - Palindromic Number Time Limit: 2 sec / Memory Limit: 256 MB Score : 100100 points Problem Statement You are given a three-digit positive integer NN.Determine whether NN is a palindromic number.Here, a palindromic nu…
打了场beginner的AtCoder,也是我第一次打AtCoder,虽然AK了,但是由于手速慢+撒比,才#471… 比赛链接:https://beta.atcoder.jp/contests/abc070 T1.题意:给一个三位数,判断是否回文 #include<cstdio> #include<iostream> #include<cstring> #include<cstdlib> #include<algorithm> using nam…
Colorful Tree 思路: 如果强制在线的化可以用树链剖分. 但这道题不强制在线,那么就可以将询问进行差分,最后dfs时再计算每个答案的修改值, 只要维护两个数组就可以了,分别表示根节点到当前节点某个颜色的个数和某个颜色长度和 代码: #pragma GCC optimize(2) #pragma GCC optimize(3) #pragma GCC optimize(4) #include<bits/stdc++.h> using namespace std; #define y1…
题意 n个点的树k种颜色,距离不超过2的点对需颜色不同,求方案数 Code(copy) #include<iostream> #include<cstdio> #include<cstdlib> #include<cstring> #include<algorithm> typedef long long LL; const int N=100005; const int MOD=1000000007; int n,k,jc[N],ny[N],a…
AtCoder Beginner Contest 177 题解 目录 AtCoder Beginner Contest 177 题解 A - Don't be late B - Substring C - Sum of product of pairs D - Friends E - Coprime F - I hate Shortest Path Problem A - Don't be late 问你能不能在时间\(T\)内用不高于\(S\)的速度走过\(D\)的路程,转化为判断\(ST\)…
AtCoder Beginner Contest 173 题解 目录 AtCoder Beginner Contest 173 题解 A - Payment B - Judge Status Summary C - H and V D - Chat in a Circle E - Multiplication 4 F - Intervals on Tree A - Payment 首先我们可以把所有不用找零的部分都付掉,这样就只剩下了\(A \mod 1000\)这样一个"\(A\)除以\(10…
目录 AtCoder Beginner Contest 148 题解 前言 A - Round One 题意 做法 程序 B - Strings with the Same Length 题意 做法 程序 C - Snack 题意 做法 程序 D - Brick Break 题意 做法 程序 E - Double Factorial 题意 做法 程序 F - Playing Tag on Tree 题意 做法 程序 结束语 AtCoder Beginner Contest 148 题解 前言 包…
问题 D: Transit Tree Path   You are given a tree with N vertices.Here, a tree is a kind of graph, and more specifically, a connected undirected graph with N−1 edges, where N is the number of its vertices.The i-th edge (1≤i≤N−1) connects Vertices ai and…