vis

机房测试:lunch(贪心+最短路)

社会主义新天地 提交于 2019-12-03 11:29:15
题目: 分析: 由数据3得:既然所有人都要学会,肯定是越早学越优。( 贪心 重要思路) 所以转移就是: dis[v]=max( dis[u] ,L ) ,u学会之后传授给v的条件是:u先学会,传授的时间在吃饭的时间内 在最短路上转移即可 再考虑有人必须学不会的限制。 如果有一个人u没有学会,就会给他周围的人v一个限制:v不能太早学会,否则吃饭的时候v就会传授给u 所以将lim[v]定为L+1,即他们在L的时候吃饭,L+1的时候v才学会,不会传给u 先将这种传递关系用spfa预处理 再跑一边dij求出每个人最早在多久学会。(将u、v之间的连边关系视作u学会了传授给v来更新v) 转移的时候是这样转移的: dis[v]=max( L,max( dis[u],lim[v] ) ) 原因: L指在这个区间内 ,dis指 u要先学会 , lim v 指在v学会的范畴内(防止出现v太早学会而将算法传给后面的人 这就是lim的作用) #include<bits/stdc++.h> using namespace std; #define N 200005 #define ri register int #define inf 1000000007//一定要足够大 否则会错!! int tot=0,to[N<<1],head[N],nex[N<<1],l[N<<1],r[N<<1],dis[N]

Create “Add New Item Wizard” in Visual C++

匿名 (未验证) 提交于 2019-12-03 10:24:21
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: Maybe I'm not searching with the right keywords, but I'm unable to find documentation on how to make your own "Add New Item Wizard" in Visual Studio Community 2013 for C++ projects. What I want to achieve is to be able to add new extensionless source files to my C++ projects from Project > Add New Item... instead of adding a C++ Source File and deleting the .cpp extension in the Solution Explorer afterwards. First I tried to make my own template, but it turns out, that that is not possible with C++ Projects in Visual Studio. Second I tried

csp-s模拟测试98「午餐」

独自空忆成欢 提交于 2019-12-03 10:00:47
考场真是什么也没想出来 暴力都没打对,真是没救了 还好我现在稍微会了一点 有一个奇怪的子任务:不存在 确定 没有学会毒瘤算法的同学。 看上去这个子任务给的性质好像没什么用 我们还是可以推一推 贪心取L即可 证明感性理解一下 于是f[x]=min(f[x],L) 最短路形式,可以用最短路转移 然后将这个子任务推广 如果存在没有学会毒瘤算法的同学就是相当于给上述转移加了一个限制条件 例如 现有wwb,whs二人 已知wwb学习毒瘤算法时间在>R,那么就意味着这次吃饭时whs也不会毒瘤算法 仍然贪心考虑 whs和wwb二人吃饭于L,然后whs在L+1学会毒瘤算法,就满足限制了 于是lim[x]=max(L+1) 先把lim算出来,再转移f就可以了 #include<bits/stdc++.h> using namespace std; #define ll long long #define A 1111111 ll n,m,tot; ll vis[A],mn[A],mx[A],head[A],nxt[A],ver[A],dis[A],flag[A],lst[A],lim[A]; struct node{ ll x,y,l,r; node(){} node(const ll &a,const ll &b,const ll &c,const ll &d){x=a,y=b,l=c,r=d;}

Git pending changes file preview in Visual Studio 2013 RC

匿名 (未验证) 提交于 2019-12-03 09:14:57
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: How do I get a "diff preview" option inside Visual Studio 2013 RC when working with Git? Most other source control extensions have this (including Git Source Control Provider , which I used in VS2012), where the list of uncommitted changes are listed to the left, and a color-coded diff of the selected file is shown on the right. I can get diffs for individual files by looking in Team Explorer, Changes, right-clicking on an individual file, then selecting Compare with unmodified. But I have to do this for each file I want to see the current

Pros and Cons of Xamarin Vis a Vis other frameworks

匿名 (未验证) 提交于 2019-12-03 08:52:47
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: I am a C# developer, entrusted with a project to develop the Android native app for one of our project, whose logic engine in C# is exposed as a REST service. Current project has a Web version using Html5 and JS and desktop using WPF. We have good Html5, Angular JS developers at our disposal, now after little research to understand what I need to do to get started, following is my understanding: Learn Java / Python for native Android development, it has some learning curve vis a vis other options Use frameworks like Cordova,

06-图1 列出连通集 (25 分)

扶醉桌前 提交于 2019-12-03 07:50:07
给定一个有 N个顶点和 E条边的无向图,请用DFS和BFS分别列出其所有的连通集。假设顶点从0到 N − 1编号。进行搜索时,假设我们总是从编号最小的顶点出发,按编号递增的顺序访问邻接点。 输入格式: 输入第1行给出2个整数 N( 0)和 E,分别是图的顶点数和边数。随后 E行,每行给出一条边的两个端点。每行中的数字之间用1空格分隔。 输出格式: 按照"{ v ​ 1 ​​ v ​ 2 ​​ ... v ​ k ​​ }"的格式,每行输出一个连通集。先输出DFS的结果,再输出BFS的结果。 输入样例: 8 6 0 7 0 1 2 0 4 1 2 4 3 5 输出样例: { 0 1 4 2 7 } { 3 5 } { 6 } { 0 1 2 7 4 } { 3 5 } { 6 } #include<cstdio> #include<cstring> #include<queue> #include<algorithm> using namespace std; const int maxn = 15; const int INF = 100000000; bool vis[maxn]; int G[maxn][maxn]; void DFS(int v,int n); void BFS(int v,int n); int main() { int n,m; scanf("%d%d",

洛谷P5020 货币系统 题解 模拟

自作多情 提交于 2019-12-03 07:13:07
题目链接: https://www.luogu.org/problem/P5020 这道题目是一道模拟题,但是又有一点多重背包的思想在里面。 首先我们定义一个 vis[i] 来表示和为 i 的情况在之前有没有出现过, 一开始当然所有的 vis[i] (除了 vis[0] )都为 false ,只有 vis[0] 为 true , 然后对于每一个 i 来说,我们从 a[i] 到 maxa (最大值)去判断 vis[j-a[i]] 是否为 true , 如果 vis[j-a[i]] 为 true ,那么 vis[j] 理应为 true ,所以需要将 vis[j] 置为 true , 但是在置为 true 之前还需要判断一下 vis[j] 是不是已经为 true 了, 如果 vis[j] 已经为 true 了,那么就是说我这一步置不置为 true 没有必要了, 如果对于所有的 j ,我置不置为 true 都没有必要了,那么我就没有必要要这个 a[i] 了。 当然我们首先得给所有的 a[i] 从小到大排序,因为这里涉及到了一丢丢贪心的思想,那就是: 小的永远比大的重要~ 依据这样的思想,实现代码如下: #include <bits/stdc++.h> using namespace std; const int maxn = 110, maxa = 25010; int T, n, m,

bfs--电梯

旧时模样 提交于 2019-12-03 06:45:51
计院有一个bug电梯,可能是hyk造的,很多bug,电梯只有两个按钮,“上”和“下”,电梯每层都可以停,每层都有一个数字Ki(0<=Ki<=n),当你在一层楼,你按“上”键会到1+K1层,你按“下”键会到1-K1层。当然,电梯不能升到N以上,也不能降到1以下。例如,有一个五层楼的建筑,k1=3,k2=3,k3=1,k4=2,k5=5。从第一层开始,你可以按“上”按钮,然后你就上到第四层,如果在第一层按“下”按钮,电梯就不能做到,因为你知道它不能下到负二层。负二楼不存在。 那么,你想从A层到B层,你至少要按多少次“上”或“下”按钮呢?Input输入由几个测试用例组成,每个测试用例包含两行。 第一行包含三个整数n,a,b(1<=n,a,b<=200),如上文所述,第二行包含n个整数k1,k2,….kn。 单个0表示输入的结束。 Output对于每种情况下的输入输出一个整数,当你在A层,你必须按下按钮的最少次数,你想去B层。如果你不能到达B层,打印“-1”。 Sample Input 5 1 5 3 3 1 2 5 0 Sample Output 3令人(我)费解的bfs,代码乱成一锅粥。每次可上可下,依次放入队列(实时更新?),判断边界且没有走过(不然会死循环)。 1 #include <iostream> 2 #include <queue> 3 #include <cstdio>

codeforces #597 div2 ABCD !F

你。 提交于 2019-12-03 06:45:17
A. Good ol' Numbers Coloring Description 给出两个整数x,y,问$ax+by,a \geq 0,b \ geq 0$不能表示的正整数是否为无穷多个。 Solution 由裴属定理可以知道当$gcd(x,y)|m$时,等式$ax+by=m$一定存在整数解。 那么显然判断条件就是$gcd(x,y)==1$ B. Restricted RPS Description 已知Bob的剪刀石头布序列。 Alice本人剪刀石头布的次数给定,$a+b+c=n$ Alice至少赢Bob$\lceil \frac{n}{2} \rceil$局才能获胜。 问Alice能否获胜,若可以,给出一组答案序列。 Solution 贪心。 由于总的方案一定 先把能赢的选出来,剩下的随便填入即可。 1 #include <algorithm> 2 #include <cctype> 3 #include <cmath> 4 #include <cstdio> 5 #include <cstdlib> 6 #include <cstring> 7 #include <iostream> 8 #include <map> 9 #include <numeric> 10 #include <queue> 11 #include <set> 12 #include <stack>

復健-搜索(10/14)

南笙酒味 提交于 2019-12-03 06:44:10
代碼水平下降嚴重,注意:Simple is Beautiful 10/14 缺: POJ 3984 HDU 1241 HDU 1495 HDU 2612 ---POJ1321(n皇后衍生) 模板題 1A 1 #define LOCAL 2 #include <cstring> 3 #include <iostream> 4 #include <sstream> 5 #include <fstream> 6 #include <string> 7 #include <vector> 8 #include <deque> 9 #include <queue> 10 #include <stack> 11 #include <set> 12 #include <map> 13 #include <algorithm> 14 #include <functional> 15 #include <utility> 16 #include <bitset> 17 #include <cmath> 18 #include <cstdlib> 19 #include <ctime> 20 #include <cstdio> 21 using namespace std; 22 #define X_mem(x,y,z) (X_mem[x][y][z] ? X_mem[x][y][z] :X_mem