```cpp
#include<iostream>
#include<cstdio>
#include<cstdlib>
using namespace std;
const int maxn=200000;
const int maxm=9000000;
struct node{
int to,next,val;
}way[3000];
int way_long=0,head[330],vis[330]={0},best[330];
int d,p,c,f,s;
void add(int now,int to,int w)
{
way_long++;
way[way_long].next=head[now];
way[way_long].to=to;
way[way_long].val=d-w;
head[now]=way_long;
}
void run(int now,int have,int from)
{
if(vis[now]==1&&way[from].val>0)
{
cout<<-1;return;
}
if(have<=best[now])
return;
best[now]=have;
vis[now]=1;//我来过
for(int i=head[now];i!=0;i=way[i].next)
{
run(way[i].to,have+way[i].val,i);
vis[way[i].to]=0;
}
}
int main()
{
cin>>d>>p>>c>>f>>s;
int want,to,w;
for(int i=1;i<=p;i++)
{
cin>>want>>to;
add(want,to,0);
}
for(int i=1;i<=f;i++)
{
cin>>want>>to>>w;
add(want,to,w);
}
//建图完成 可能有环和负数
for(int i=1;i<=c;i++)
best[i]=-maxm;//初始化
run(s,d,0);
int biggest=-1;
for(int i=1;i<=c;i++)
if(best[i]>biggest)
biggest=best[i];
cout<<biggest;
}
/*
100 2 3 1 1
1 3
1 2
2 3 50
*/
```
# 就是因为我判断了是否有环输出-1我就的了91
# 删了那句就AC了,,数据真水
by Freddie @ 2018-02-27 09:30:56
# 用个DFS就完成了****
by Freddie @ 2018-02-27 09:40:17
# somebody
## somebody
### somebody
#### somebody
##### somebody
###### somebody
by 加载错误 @ 2018-02-27 10:03:37
# 放在Dcv-C++项目里面,运行
```cpp
#include <windows.h>
#define NUM 32767
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
PSTR szCmdLine, int iCmdShow)
{
static int iKeep[NUM][4];
HDC hdcScr, hdcMem;
int cx, cy;
HBITMAP hBitmap;
HWND hwnd;
int i, j, x1, y1, x2, y2;
if (LockWindowUpdate(hwnd = GetDesktopWindow()))
{
hdcScr = GetDCEx(hwnd, NULL, DCX_CACHE | DCX_LOCKWINDOWUPDATE);
hdcMem = CreateCompatibleDC(hdcScr);
cx = GetSystemMetrics(SM_CXSCREEN) / 10;
cy = GetSystemMetrics(SM_CYSCREEN) / 10;
hBitmap = CreateCompatibleBitmap(hdcScr, cx, cy);
SelectObject(hdcMem, hBitmap);
srand((int)GetCurrentTime());
for (i = 0; i < 2; i++)
for (j = 0; j < NUM; j++)
{
LockWindowUpdate(hwnd = GetDesktopWindow());
if (i == 0)
{
iKeep[j][0] = x1 = cx * (rand() % 10);
iKeep[j][1] = y1 = cy * (rand() % 10);
iKeep[j][2] = x2 = cx * (rand() % 10);
iKeep[j][3] = y2 = cy * (rand() % 10);
}
else
{
x1 = iKeep[NUM - 1 - j][0];
y1 = iKeep[NUM - 1 - j][1];
x2 = iKeep[NUM - 1 - j][2];
y2 = iKeep[NUM - 1 - j][3];
}
BitBlt(hdcMem, 0, 0, cx, cy, hdcScr, x1, y1, SRCCOPY);
BitBlt(hdcScr, x1, y1, cx, cy, hdcScr, x2, y2, SRCCOPY);
BitBlt(hdcScr, x2, y2, cx, cy, hdcMem, 0, 0, SRCCOPY);
}
DeleteDC(hdcMem);
ReleaseDC(hwnd, hdcScr);
DeleteObject(hBitmap);
}
return 0;
}
```
by 加载错误 @ 2018-02-27 10:07:14
# dd
by Da_Capo_ @ 2018-07-30 10:30:07
# dd
## dd
### dd
#### dd
##### dd
###### dd
**dd**
_dd_
~~dd~~
by Da_Capo_ @ 2018-07-30 10:31:54
可是为什么加上-1判断就错了呢
by Sirius_X @ 2018-10-12 20:24:59
好吧,是我环判错了
by Sirius_X @ 2018-10-12 20:51:56
这算啥,我因为太久没写SPFA了,把标记数组写错了,都有30分
by lemir3 @ 2019-06-20 20:48:55