英雄灭火问题忽略了一点丫 一个超级源点的事情,需要考虑周全丫 2 #include<cstdio>#include<cstring>#include<queue>#include<vector>#include<iostream>#include<algorithm>using namespace std;#define maxn 1010#define INF 0x3f3f3f3fin
题目链接:https://nanti.jisuanke.com/t/41384 这题暴力能过,我用的是并查集的思想,这个题的数据是为暴力设置的,所以暴力挺快的,但是当他转移的点多了之后,我觉得还是我这种方法更好一点。注意这里一定要用内部是hash的unordered_map 做,因为查询为o(1) #include <iostream> #inc
Carneginon was a chic bard. But when he was young, he was frivolous and had joined many gangs. Recently, Caneginon was to be crowned, because the king was shocked by his poems and decided to award him the gold medal lecturer. Therefore, Most of people in
2019-ACM-ICPC-南京区网络赛-E. K Sum-杜教筛+欧拉定理 【Problem Description】 令\(f_n(k)=\sum_{l_1=1}^n\sum_{l_2=1}^n\dots\sum_{l_k=1}^n gcd(l_1,l_2,\dots,l_k)\)。求\(\sum_{i=2}^kf_n(i)\ mod \ (10^9+7)\)。 【Solution】 对于\(f_n(k)\)有: \[ \sum_{l_1=1}^n\sum_{
A. The beautiful values of the palace 求出每个点的权值, 然后树状数组扫描线 #include <iostream>#include <sstream>#include <algorithm>#include <cstdio>#include <cmath>#include <set>#include <map>#include <queue>#include <s
Rank Solved A B C D E F G H I 157/1361 4/9 O O . Ø . O . O . O: 当场通过 Ø: 赛后通过 .: 尚未通过 A The beautiful values of the palace solved by viscaria&chelly chelly’s solution 找到坐标和权值的对应关系,就是一个简单的二维数点。 B super_log
Holy Grail 限制 1000 ms 256 MB As the current heir of a wizarding family with a long history,unfortunately, you fifind yourself forced to participate in the cruel Holy Grail War which has a reincarnation of sixty years.However,fortunately,you summoned a
【ICPC银川网络赛F题】题目大意:t组数据。有n个城市,每个城市有ai点危险值。给定一个邻接矩阵即两个城市的距离。有q组询问,问从u城市到v城市在不经历w危险值城市的情况下最短路是多少。 【luogu1119灾后重建】题目大意:给定n个点和m条边,每个点的重修时间为ti。有q组询问,问从u
ICPC 2019宁夏网络赛 Maximum Element In A Stack Rolling The Polygon Caesar Cipher Take Your Seat Moving On #include<bits/stdc++.h>using namespace std;typedef long long ll;int n,m,k,q;int dp[210][210][210];int d[210],id[210];bool cmp(int x,int y)
In cryptography, a Caesar cipher, also known as the shift cipher, is one of the most straightforward and most widely known encryption techniques.It is a type of substitution cipher in which each letter in the plaintext is replaced by a letter some fix
题面 很容易看出来是最小割,然后打出模板后发现答案错了(甚至建边都是x->y,我佛了看了半天),一看题解才知道无向图不一样,建图反向边权值也是val,虽然不知道为啥,不过说的是本来就可以增广 记住就行???? #include<bits/stdc++.h>using namespace std;const int maxn=1000005;const int maxm=
描述Michael喜欢滑雪百这并不奇怪, 因为滑雪的确很刺激。可是为了获得速度,滑的区域必须向下倾斜,而且当你滑到坡底,你不得不再次走上坡或者等待升降机来载你。Michael想知道载一个区域中最长的滑坡。区域由一个二维数组给出。数组的每个数字代表点的高度。下面是一个例子 1 2 3 4
E. 0:19:15 solved by hl 按照题意模拟即可 #include <iostream>#include <cstdio>#include <cmath>#include <cstring>#include <cstdio>#include <queue>#include <map>#include <set>#include <algorithm>using namespa
Abiyoyo /* * [链接]:https://nanti.jisuanke.com/t/A1530 * * [题意]:复读机 * * [分析]: * * [tricks]: * * [时间复杂度] * * * * * * */ #include <bits/stdc++.h> #define ll long long using namespace std; void scan() { #ifndef ONLINE_JUDGE
思路:首先需要明确我们只要每次操作合并两个,那么总能使得最后合并成一个。下面我们给出两个点合并的方法,先任意选择两个点a和b,求出两个点之间的最短路。然后让所有点都按照该路径进行移动。那么最后a点会到达b点,b点会到达c。 下面我们证明 现在的状态不会和原来的状态重合(因为
前言 在ICPC比赛前,为了在赛场上比较高效的书写代码,各位ACMer往往会提前准备好一份或是他人整理的,亦或是自己整理的板子。 而在我们整理板子的过程中,因为word文档的局限性,我们往往会对模板的排版而绞尽脑汁,而如果我们花大量的时间在排版上,或许也太过与得不偿失。因此此时就需要我们
Then n - 1n−1 lines follow. ii-th line contains two integers f_{a_i}(1 \le f_{a_i} < i)fai(1≤fai<i), w_i(0 \le w_i \le 10^{18})wi(0≤wi≤1018) —The parent of the ii-th node and the edge weight between the ii-th node and f_{a_i} (ifai
题目 Define the function S(x) for xx is a positive integer. S(x) equals to the sum of all digit of the decimal expression of x. Please find a positive integer k that S(k∗x)%233=0. Input Format First line an integer T, indicates the number of test cases
题目连接 Problem There is a tree with n nodes. For each node, there is an integer value a_iai, (1 \le a_i \le 1,000,000,0001≤ai≤1,000,000,000 for 1 \le i \le n1≤i≤n). There is qq queries which are described as follow: Assume the value on the
A 表达式求值 表达式求值:可以用递归求解,也可以用栈模拟,考过多次。 类似题目:NYOJ305,NYOJ35 用栈模拟做法: #include <stdio.h> #include <string.h> #include <stack> using namespace std; stack<int> dsta;//数据栈 stack<char> osta;//字符栈 char s[1005]; int main() {
刻苦的训练我打算最后稍微提一下。主要说后者:什么是有效地训练? 我想说下我的理解。 很多ACMer入门的时候,都被告知:要多做题,做个500多道就变牛了。其实,这既不是充分条件、也不会是必要条件。 我觉得一般情况下,对于我们普通学校的大学
解题过程 中午吃饭比较晚,到机房lfw开始发各队的账号密码,byf开始读D题,shl电脑卡的要死,启动中...然后听到谁说A题过了好多,然后shl让blf读A题,A题blf一下就A了。然后lfw读完M题(shl的电脑终于打开了,然后输入密码,密码错误。。。自闭),说AC 自动机板题,然后找板子,,,突然发现自己读错题目。后
题目链接:https://codeforces.com/gym/102028 B. Ultraman vs. Aodzilla and Bodzilla 题意: 两只怪兽,它们的生命和攻击分别为hpA,hpB,attA,attB,现在你要打败它们,第i回合你的攻击为i。问在承受伤害最少的前提下,攻击序列字典序最小是怎样的。攻击A就是A,攻击B就是B。最后输出承受的最小
Azulejos Azulejo in the cathedral of Porto. Source: Wikimedia Commons Ceramic artists Maria and João are opening a small azulejo store in Porto. Azulejos are the beautiful ceramic tiles for which Portugal is famous. Maria and João want to create an
Ceiling Function 签到题,暴力 1 #include <bits/stdc++.h> 2 using namespace std; 3 const int maxn = 1e5 + 10; 4 int rt[maxn], ls[maxn], rs[maxn], val[maxn], cnt; 5 6 void add(int x, int v) { 7 if(v < val[x]) { 8 if(ls[x]) add(ls[x], v);