2018 ACM-ICPC World Finals Gym-102482C Conquer the World

题目传送门

分析:
费用流,然而不会优化,在线膜拜大佬的博客OrzOrzOrz

#include
#include
#include
#include
#include
#include

#define maxn 1000005
#define INF (1ll<<40)
#define MOD 998244353

using namespace std;

inline int getint()
{
	int num=0,flag=1;char c;
	while((c=getchar())<'0'||c>'9')if(c=='-')flag=-1;
	while(c>='0'&&c<='9')num=num*10+c-48,c=getchar();
	return num*flag;
}

int n,m;
priority_queue,greater >Q1[maxn],Q2[maxn];
int A1[maxn],A2[maxn];
int fir[maxn],nxt[maxn],to[maxn],len[maxn],cnt;
long long dis[maxn],ans;

inline void newnode(int u,int v,int w)
{to[++cnt]=v,nxt[cnt]=fir[u],fir[u]=cnt,len[cnt]=w;}

inline void merge(int x,int y)
{
	if(Q1[x].size()

你可能感兴趣的:(2018 ACM-ICPC World Finals Gym-102482C Conquer the World)