题意:有一些无向边m条权值是给定的k条权值在[l,r]区间可以由你来定,一个点s1 出发一个从s2出发  问s1 出发的能不能先打到f

思路:最短路。

首先检测能不能赢 在更新的时候  如果对于一条边 a->b  如果dis1[a] <dis2[a]  那么选择这条边就选择   l  因为这条边对于s1有利 如果两个起点都选择了这条边  则说明s1 赢定了,所以要让他们尽量走这条,所以边权越小越好。跑完之后检测 如果  dis1[f]<dis2[f] 那么 就赢了。

接下来判断能不能平局。因为目前已经没有赢的可能了  那么  把dis1[a]<dis2[a]改成dis1[a]<=dis2[a] 选择l  其他选择r 即可。原因:小于的话毫无疑问就是选择l  ;等于的话选择小的如果两个都走了这条边则平局。

#include<cstring>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include <iostream>
#include<vector>
#include<queue>
#define INF 1e15
#define LL long long
#define P pair<LL,int>
#define MP make_pair
#define M 200000
#define N 100000
using namespace std;
priority_queue<P> q;
struct node {
int l, r, to, nx;
} e[M];
int head[N];
int ecnt;
int ans[N];
void addedge(int x, int y, int l, int r) {
e[ecnt].l = l;
e[ecnt].r = r;
e[ecnt].to = y;
e[ecnt].nx = head[x];
head[x] = ecnt++;
}
LL d1[N], d2[N];
int n, m, k, s1, s2, f;
void gao(int bo) {
while (!q.empty())
q.pop();
memset(ans, -, sizeof(ans));
for (int i = ; i <= n; ++i)
d1[i] = d2[i] = INF;
d1[s1] = d2[s2] = ;
q.push(MP(, s1));
q.push(MP(, s2));
while (!q.empty()) {
P ee = q.top();
q.pop();
LL va = -ee.first;
int id = ee.second;
if (va > d1[id] && va > d2[id])
continue;
bool ok;
if (bo == ) {
if (d1[id] < d2[id])
ok = true;
else
ok = false;
} else {
if (d1[id] <= d2[id])
ok = true;
else
ok = false;
}
for (int i = head[id]; i != -; i = e[i].nx) {
int u = e[i].to;
LL add;
if (ok)
add = e[i].l;
else
add = e[i].r;
ans[i] = add;
if (d1[u] > d1[id] + add) {
d1[u] = d1[id] + add;
q.push(MP(-d1[u], u));
}
if (d2[u] > d2[id] + add) {
d2[u] = d2[id] + add;
q.push(MP(-d2[u], u));
}
}
}
}
int main() {
scanf("%d%d%d", &n, &m, &k);
scanf("%d%d%d", &s1, &s2, &f);
memset(head, -, sizeof(head));
ecnt = ;
for (int i = ; i < m; ++i) {
int x, y, z;
scanf("%d%d%d", &x, &y, &z);
addedge(x, y, z, z);
}
for (int i = ; i < k; ++i) {
int x, y, l, r;
scanf("%d%d%d%d", &x, &y, &l, &r);
addedge(x, y, l, r);
}
gao();
if (d1[f] < d2[f]) {
puts("WIN");
for (int i = m; i < m + k; ++i) {
if (ans[i] == -)
ans[i] = e[i].l;
printf("%d", ans[i]);
if (i == m + k - )
puts("");
else
printf(" ");
}
return ;
}
gao();
if (d1[f] == d2[f]) {
puts("DRAW");
for (int i = m; i < m + k; ++i) {
if (ans[i] == -)
ans[i] = e[i].l;
printf("%d", ans[i]);
if (i == m + k - )
puts("");
else
printf(" ");
}
return ;
}
puts("LOSE");
return ;
}

CodeForces 360E Levko and Game(Codeforces Round #210 (Div. 1))的更多相关文章

  1. (BestCoder Round #64 (div.2))Array

    BestCoder Round #64 (div.2) Array 问题描述 Vicky是个热爱数学的魔法师,拥有复制创造的能力. 一开始他拥有一个数列{1}.每过一天,他将他当天的数列复制一遍,放在 ...

  2. Codeforces Round #433 (Div. 2)【A、B、C、D题】

    题目链接:Codeforces Round #433 (Div. 2) codeforces 854 A. Fraction[水] 题意:已知分子与分母的和,求分子小于分母的 最大的最简分数. #in ...

  3. CodeForces 816B Karen and Coffee(前缀和,大量查询)

    CodeForces 816B Karen and Coffee(前缀和,大量查询) Description Karen, a coffee aficionado, wants to know the ...

  4. 【CodeForces】841D. Leha and another game about graph(Codeforces Round #429 (Div. 2))

    [题意]给定n个点和m条无向边(有重边无自环),每个点有权值di=-1,0,1,要求仅保留一些边使得所有点i满足:di=-1或degree%2=di,输出任意方案. [算法]数学+搜索 [题解] 最关 ...

  5. CodeForces - 1207G :Indie Album(AC自动机 fail树上DFS)

    题意:有N个串,给出的形式是拼接给出,对于第i行:  (1,c)表示字符串i是单个字母c: (2,p,c)表示字符串i=在字符串p后面接上一个字母c. 然后给出M个提问,形式是(i,string).问 ...

  6. 「日常训练」Skills(Codeforce Round #339 Div.2 D)

    题意(CodeForces 614D) 每个人有\(n(n\le 10^5)\)个技能,技能等级都在\([0,10^9]\)的范围,每个技能有一个当前等级,所有技能的最高等级都为A.一个人的力量被记做 ...

  7. 「知识学习&日常训练」莫队算法(一)(Codeforce Round #340 Div.2 E)

    题意 (CodeForces 617E) 已知一个长度为\(n\)的整数数列\(a[1],a[2],-,a[n]\),给定查询参数\(l,r\),问\([l,r]\)内,有多少连续子段满足异或和等于\ ...

  8. B. Ohana Cleans Up(Codeforces Round #309 (Div. 2))

    B. Ohana Cleans Up   Ohana Matsumae is trying to clean a room, which is divided up into an n by n gr ...

  9. B. The Number of Products(Codeforces Round #585 (Div. 2))

    本题地址: https://codeforces.com/contest/1215/problem/B 本场比赛A题题解:https://www.cnblogs.com/liyexin/p/11535 ...

随机推荐

  1. hibernate中load和get方法的区别

    1.读取时机不同(当lazy=true的时候)    load是采用延迟机制(load语句不读库,等使用非主键时才去读库),而get不采用延  迟机制(get语句时马上读库): 2.搜索不到数据时的情 ...

  2. [python]用Python进行SQLite数据库操作

    用Python进行SQLite数据库操作 1.导入Python SQLITE数据库模块 Python2.5之后,内置了SQLite3,成为了内置模块,这给我们省了安装的功夫,只需导入即可~  ]: u ...

  3. 十六、Java基础---------集合框架之Set

    写在前面的话,这篇文章在昨天就写好了,今天打开的时候一不小心将第二天的文章粘贴到了这篇文章,很不幸的是除了标题之外依然面目全非,今天带着沉痛的心情再来写这篇文章! 上篇文章介绍了Collection体 ...

  4. stack overflow--技术问答网站

    转自:http://baike.baidu.com/link?url=eMR6Pwdk9IkauI5B3nZb2Yo3VUAcK6vQfrMpcSMPWqgH0ngqFkup3Gdr3t_s_yZe_ ...

  5. udhcpc命令【转】

    udhcpc -i usb0 route 转自:http://blog.csdn.net/hshl1214/article/details/8684740 由于要使用网络通讯,所以不可避免的要用到dh ...

  6. 认真分析mmap:是什么 为什么 怎么用【转】

    转自:http://www.cnblogs.com/huxiao-tee/p/4660352.html?utm_source=tuicool&utm_medium=referral 阅读目录 ...

  7. ie11媒体查询以及其他hack

    <!doctype html> <html> <head> <title>IE10/11 Media Query Test</title> ...

  8. 隐式意图Intent

    在我们想往下一个页面传递数据时,要想到显式意图和隐式意图,显示意图用于内部活动跳转时比较方便,而隐式意图用于应用程序中外部活动的跳转时较为方便,在使用隐式意图时我们要想到清单文件 代码如下: < ...

  9. CSS中的浮动问题

    有关于我们经常做的导航问题.我们如果想用ul>li来做导航的话,我是一般是用到浮动这个属性的. 也就是 float:left; 或者是 display:inline-block;  下边代码: ...

  10. 从零开始学习jQuery(转)

    本系列文章导航 从零开始学习jQuery (一) 开天辟地入门篇 从零开始学习jQuery (二) 万能的选择器 从零开始学习jQuery (三) 管理jQuery包装集 从零开始学习jQuery ( ...