CODEFORCES 269C Flawed Flow
来源:互联网 发布:淘宝图片批量处理软件 编辑:程序博客网 时间:2024/05/28 23:11
题目:http://codeforces.com/contest/269/problem/C点击打开链接
题意:给你一张图和流量,使得流量最大,求各边的流的方向?
分析:所有输入流等于输出流
input
4 51 2 101 3 102 3 54 2 153 4 5
output
00110
#include <cstdio>#include <iostream>using namespace std;const int M=400400;int n,m,b[M],c[M],e[M],h[M],d[M],k=2,q[M],l,t,f[M],v[M];int main(){ scanf("%d%d",&n,&m); for(int x,y,z,i=0; i<m&&3==scanf("%d%d%d",&x,&y,&z); ++i) { b[k]=y,c[k]=z,e[k]=h[x],h[x]=k++,d[x]+=z; b[k]=x,c[k]=z,e[k]=h[y],h[y]=k++,d[y]+=z; } d[n]*=2,v[q[t++]=1]=1; while(l<t) { for(int i=h[q[l++]]; i>0; i=e[i])if(!v[b[i]]) { f[i/2]=i&1; if((d[b[i]]-=c[i]*2)<1)v[q[t++]=b[i]]=1; } } for(int i=1; i<=m; ++i)puts(f[i]?"1":"0"); return 0;}
1 0
- CODEFORCES 269C Flawed Flow
- CodeForces 269C Flawed Flow 拓扑
- Codeforces 270E Flawed Flow【思维+类拓扑排序】
- Digital encryption standard flawed
- LoadLibraryEx(DONT_RESOLVE_DLL_REFERENCES) is fundamentally flawed
- 新产品开发之C流程 (C-flow)
- flow
- flow
- flow
- flow
- flow
- flow
- 1.4C++编程流程(C++Programming Flow)
- The Flow Chart of Running C Program
- Codeforces Round #269 (Div. 2) C
- codeforces Round #269(div2) C解题报告
- Codeforces Round #269 (Div. 2) C
- Codeforces-340-C(c++)
- amazon服务器下使用FileZilla上传文件到服务器
- OpenCV学习笔记(二):腐蚀与膨胀
- 信息检索导论——一、布尔检索
- 下拉框左右选择
- ibatis 日期格式比较
- CODEFORCES 269C Flawed Flow
- kaptcha验证码在spring mvc中的使用
- bean的加载(十一)初始化bean
- 配置freeglut和glew
- SpringMVC路径重复报错
- maven编译的时候出现一大堆Test相关的错误
- JVM内存模型和启动参数的关系
- POI操作excel基本使用
- Retrofit网络框架搭建