这一题学到的东西太多了 1.大数组不能开在函数中,要使用全局变量 2.bellman_ford算法 3.c语言中struct不能有构造函数,开数组不能使用const的值作为大小,而要用define. 4.代替vector的建图方法,数组模拟链表法,map[i]存第i个点的第一条边在e中的下标。e用来存边,next记录该点的下一条边的坐标。 5.使用vector的效率极低。 本题只需建正...
转载
2011-02-01 14:19:00
25阅读
2评论
题意:求出每个前缀的最长周期之和(等于本身的算0) 思路: 求出来next数组 建出next树 找到不为0的最小的 n减去它就是答案
转载
2017-04-05 09:28:00
26阅读
2评论
#include<iostream> //Dijkstra+优先队列 1735MS!#include<queue>#define maxn 1000002using namespace std;struct Edge { int v; int weight; int next;}Vertex[maxn];int head[maxn],curr; const __int64 inf=(__int64)1<<63-1; int cases,p,e,i,j,edge[maxn][3];void graph(int tag){ int u,v,w; curr=0;
转载
2011-07-22 22:34:00
50阅读
Invitation CardsTime Limit: 8000MSMemory Limit: 262144KTotal Submissions: 15101Accepted: 4897DescriptionIn the age of television, not many people attend theater performances. Antique Comedians of Malidinesia are aware of this fact. They want to propagate theater and, most of all, Antique Comedies. T
原创
2021-07-29 16:22:39
77阅读
Invitation Cards 翻译: 描述 在电视时代,没有多少人参加戏剧表演。 Malidinesia古董喜剧演员知道这个事实。他们想传播戏剧,最重要的是古董喜剧。他们已经印制了包含所有必要信息和程序的邀请卡。许多学生被聘请将这些邀请分发给人们。每个学生志愿者都分配了一个公交车站,并且他或她在
转载
2018-06-29 16:04:00
51阅读
2评论
问题描述在花园里有N颗树,我现在想拿一根绳子将其全部包围。求最小的绳子长度。输入
题目大意:有编号从一号到n号的n个点,m条路,问从一号到其他点,再从其他点回到一号,每个点都要走一次,问总路程最短多少。解题思路:因为数据量很大,用一般的dijkstra的话,二维数组也太大了,开不了。所以用spfa求。首先要学用邻接表示图,这样省空间,省时间,先看这篇博客学习一下(http://ahalei.blog.51cto.com/4767671/1391988)然后spfa的方法就是,首
原创
2021-12-01 13:41:12
37阅读
数据太大,heap优化是必须的,然后不能用vector建图,即
原创
2022-08-17 15:38:27
25阅读
DescriptionIn the age of television, not many people attend theater performances. Antique Comedians of Malidinesia are aware of this fact. They want to propagate theater and, most of all, Antique Comedies. They have printed invitation cards with all the n
原创
2022-02-15 11:06:22
29阅读
DescriptionIn the age
of television, not many people attend theater performances.
【题目链接】:http://hihocoder.com/problemset/problem/1511【题意】 【题解】 有个方差的公式 V(X)=E(X2)−E(X)2 这里E(X)指的是X的期望; 显然所有树的度数的期望都是2*(n-1)/n 则问题转换成求E(X^2)了; 这...
转载
2017-10-04 18:44:00
72阅读
2评论
DescriptionIn the age of television, not many people attend theater performances. Antique Comedians of Malidinesia are aware of this fact. They want to propagate theater and, most of all, Antique Comedies. They have printed invitation cards with all the n
原创
2021-08-10 10:10:34
48阅读
链接:https://vjudge.net/problem/POJ-1511#author=scu2017 题意: B208的小姐姐们想去学校各地宣传ACM,但是让小姐姐们跑太远的路总是不太好的,因此麻烦G学长帮小姐姐们计算一下,小姐姐们到各地宣传再回到B208的最短路径总和是多少。已知:学校一共有
转载
2019-01-16 18:44:00
33阅读
2评论
题目链接:http://acm.uestc.edu.cn/problem.php?pid=1511思路:我们可以等到这样的5个关系式:k=1:dsit[a]-dist[b]>=0&&dist[b]-dist[a]>=0k=2:dist[a]-dist[b]=0;k=4:dist[a]-dist[b]>=1;k=5:dist[a]-dist[b] 2 #include 3 #include 4 #include 5 #include 6 using namespace std; 7 #define MAXN 100200 8 #define inf 1 >
转载
2013-09-15 09:22:00
15阅读
2评论
https://vjudge.net/problem/UVA-1151 题意,给出N个点以及二维坐标,可以在任意两点间建立通路,代价是两点欧几里得距离的平方,同时有q个套餐,套餐x有qx个点,代价是qw, 花费qw就能将这qx个点全部相联通,套餐可以任意选择几种或不选,求将所有的点联通所要的最小代价
转载
2017-08-12 18:49:00
46阅读
2评论
考虑计数拆开贡献。 因为在一个方案中一个格子最多只会贡献一次,那么不妨反过来求这个格子贡献了多少次。 然后发现,行列独立,那么我们单独计算红蓝色,即可。 一个偶数块贡献当且仅当前面也是偶数块。 然后显然其他不在同一行/同一列的块就直接随便乱取就行了。 #include<iostream> #incl ...
转载
2021-10-27 20:34:00
25阅读
2评论
壹、题目描述 ¶ 传送门 to CF. 贰、题解 ¶ 我已经完全学懂概率与期望啦. 明白了基础不牢带给人的无限困扰。
转载
2021-07-14 20:38:00
126阅读
2评论
题目 题目链接:https://codeforces.com/problemset/problem/1511/G 一个 \(n\times m\) 的棋盘,每一行有且仅有一个石子,第 \(i\) 行的石子在第 \(a_i\) 列。 每次询问给出 \(l,r\),求把棋盘第 \(1\sim l-1\)
转载
2021-04-30 17:47:00
53阅读
2评论