CodeForces 173B Chamber of Secrets spfa】的更多相关文章

Chamber of Secrets 题目连接: http://codeforces.com/problemset/problem/173/B Description "The Chamber of Secrets has been opened again" - this news has spread all around Hogwarts and some of the students have been petrified due to seeing the basilisk…
题目链接: http://codeforces.com/problemset/problem/173/B 题意: 给你一个n*m的地图,现在有一束激光从左上角往左边射出,每遇到‘#’,你可以选择光线往四个方向射出,或者什么都不做,问最少需要多少个‘#’往四个方向射出才能使关系在n行往右边射出. 题解: 以行和列建二分图,如果str[i][j]=='#',则从i节点到j节点建一条双向边,权值都为1.然后对二分图跑一遍最短路. 代码: #include<iostream> #include<…
题意:给定上一个n*m的矩阵,你从(1,1)这个位置发出水平向的光,碰到#可以选择四个方向同时发光,或者直接穿过去, 问你用最少的#使得光能够到达 (n,m)并且方向水平向右. 析:很明显的一个最短路,但是矩阵有点大啊.1000*1000,普通的肯定要超时啊,所以先通过#把该该图的行和列建立成二分图, 然后再跑最短路,这样就简单多了. 代码如下: #pragma comment(linker, "/STACK:1024000000,1024000000") #include <c…
B. Mike and Shortcuts time limit per test: 3 seconds memory limit per test: 256 megabytes input: standard input output: standard output Recently, Mike was very busy with studying for exams and contests. Now he is going to chill a bit by doing some si…
Dwarf Tower 题目连接: http://codeforces.com/gym/100269/attachments Description Little Vasya is playing a new game named "Dwarf Tower". In this game there are n different items, which you can put on your dwarf character. Items are numbered from 1 to…
题目大意: 给定一个\(n\)的点的图.求\(s\)到所有点的最短路 边的给定方式有三种: \(u \to v\) \(u \to [l,r]\) \([l,r] \to v\) 设\(q\)为给定边的次数,有\(n,q \leq 10^5\) 题解 类比于线段树优化网络流建图 写一个线段树优化最短路建图即可. #include <queue> #include <vector> #include <cstdio> #include <cstring> #i…
题意:给你一个n*m的地图,现在有一束激光从左上角往右边射出,每遇到‘#’,你可以选择光线往四个方向射出,或者什么都不做,问最少需要多少个‘#’往四个方向射出才能使关系在n行往右边射出. 思路:将每一行,每一列看做二分图中的一个点,a[i,j]='#'就将第i行和第j列之间连一条边,最短路DFS即可. ; ..]of longint; n,m,i,j,tot,u,e,v,t,w:longint; ch:ansistring; procedure add(a,b:longint); begin i…
题意及思路:https://www.cnblogs.com/zjp-shadow/p/9562888.html 这题由于性质特殊,可以用01BFS来进行DP的转移. 代码: #include <bits/stdc++.h> using namespace std; const int maxn = 1000010; vector<int> G[maxn]; deque<int> q; int dp[maxn], deg[maxn]; bool v[maxn]; void…
问题描述在<Harry Potter and the Chamber of Secrets>中,Ron 的魔杖因为坐他老爸的 Flying Car 撞到了打人柳,不幸被打断了,从此之后,他的魔杖的魔力就大大减少,甚至没办法执行他施的魔咒,这为 Ron 带来了不少的烦恼.这天上魔药课,Snape 要他们每人配置一种魔药(不一定是一样的),Ron 因为魔杖的问题,不能完成这个任务,他请 Harry 在魔药课上(自然是躲过了 Snape 的检查)帮他配置.现在 Harry 面前有两个坩埚,有许多种药…
Names appearing in "Harry Potter" 1.Harry Potter ①Harry is from Henry. ②Harry is related to Old High German Heri, which means army. James Potter and Lily Evans 2.Hermione Granger Hands up if you had been pronouncing Hermione's name wrong when yo…