BZOJ4152 The Captain 题面很简洁: 给定平面上的n个点,定义(x1,y1)到(x2,y2)的费用为min(|x1-x2|,|y1-y2|),求从1号点走到n号点的最小费用. 很明显这是道最短路 我们知道在求最短路时本身就要不断求min 所以相对于拐弯抹角的横纵差的较小值,我们完全可以无视这个求min 转为建|x1-x2|,|y1-y2|两条边 最后跑一遍最短路即可 (ps.这题是卡SPFA的) IO优化.头文件啥的就自己yy一下吧 #define int long long
B http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=5552 输入n,表示有n个数1到n.A先拿,B后拿,依次拿,每次可以拿任意一个数,同时会删去这个数的所有因子,最后谁没得拿了谁输. 解法:推了前几个,0,a输,别的a都能赢,证明没想,猜过去的. 网上一个人说的,也不是很清晰:“如果先取的在2-n中取必输,则先取1, 否则则在2-n中取,同时会把1取走,必赢” #include<cstdio> int main(){ in
Cops and Thieves Description: The Galaxy Police (Galaxpol) found out that a notorious gang of thieves has plans for stealing an extremely valuable exhibit from the Earth Planetary Museum — an ancient microprocessor. The police chiefs decided to inter
小明的烦恼--找路径 Time Limit: 2000ms, Special Time Limit:5000ms, Memory Limit:32768KB Total submit users: 45, Accepted users: 36 Problem 11545 : No special judgement Problem description 小明真的是个非常厉害的人,每当老师有什么事时.总是会找到小明,二小明也总能解决.所以老师决定给小明一个奖励.给他额外的假期.小明当然非常
题目链接:https://www.lydsy.com/JudgeOnline/problem.php?id=1001 看到大佬们都是对偶图过的,写了个最大流水过去了QAQ,网络流的无向图直接建双向边(不用建0边),然后跑dinic,最基本的dinic会被卡,可以简单优化一下. 有空学了对偶图在补,(个_个) #include<bits/stdc++.h> using namespace std; typedef long long ll; ; const int inf = INT_MAX;