汽车加油行驶问题
题目
解析
这是一道费用流题,然而却被spfa等做法暴切
考虑分层图最短路,按剩余油量分层,枚举各种转移即可
PS:本来想打堆优化dij,后来打挂了,最后选择了spfa
code:
#include<iostream>
#include<cstring>
#include<cstdio>
#include<queue>
using namespace std;
int n,k,sx,sy,ss,use,tx,ty,dx[4]={
1,0,-1,0},dy[4]={
0,1,0,-1},A,B,C,d[110][110][12],ans=1e9;
struct tr{
int x,y,s;};
queue<tr> q;
bool ch[110][110],to[110][