#include <stdio.h>
#include <string.h>
#include <iostream>
#include <algorithm>
#include <math.h>
#include <limits.h>
#include <map>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <string>
#define ll long long
#define ms(a) memset(a,0,sizeof(a))
#define pi acos(-1.0)
#define INF 0x3f3f3f3f
const double E=exp(1);
const int maxn=1e3+10;
using namespace std;
int a[maxn][maxn];
int way[maxn];
int n,m;
void toposort()
{
for(int i=1;i<=n;i++)
{
for(int j=1;j<=n;j++)
{
if(way[j]==0)
{
way[j]--;
cout<<j;
if(i!=n)
cout<<" ";
for(int k=1;k<=n;k++)
{
if(a[j][k])
way[k]--;
}
break;
}
}
}
cout<<endl;
}
int main(int argc, char const *argv[])
{
while(cin>>n>>m&&(n||m))//这个不是&&停止!!!
{
ms(a);
ms(way);
int x,y;
for(int i=1;i<=m;i++)
{
cin>>x>>y;
a[x][y]=1;
way[y]++;
}
toposort();
}
return 0;
}

UVA 10305:Ordering Tasks(拓扑排序)的更多相关文章

  1. UVA.10305 Ordering Tasks (拓扑排序)

    UVA.10305 Ordering Tasks 题意分析 详解请移步 算法学习 拓扑排序(TopSort) 拓扑排序的裸题 基本方法是,indegree表示入度表,vector存后继节点.在tops ...

  2. UVa 10305 - Ordering Tasks (拓扑排序裸题)

    John has n tasks to do. Unfortunately, the tasks are not independent and the execution of one task i ...

  3. Uva 10305 - Ordering Tasks 拓扑排序基础水题 队列和dfs实现

    今天刚学的拓扑排序,大概搞懂后发现这题是赤裸裸的水题. 于是按自己想法敲了一遍,用queue做的,也就是Kahn算法,复杂度o(V+E),调完交上去,WA了... 于是检查了一遍又交了一发,还是WA. ...

  4. UVA 10305 Ordering Tasks(拓扑排序的队列解法)

    题目链接: https://vjudge.net/problem/UVA-10305#author=goodlife2017 题目描述 John有n个任务,但是有些任务需要在做完另外一些任务后才能做. ...

  5. Ordering Tasks UVA - 10305 图的拓扑排序

    John has n tasks to do. Unfortunately, the tasks are not independent and the execution of one task i ...

  6. UVA - 10305 Ordering Tasks(拓扑排序)

    题意:给定优先关系进行拓扑排序. 分析:将入度为0的点加入优先队列,并将与之相连的点入度减1,若又有度数为0的点,继续加入优先队列,依次类推. #pragma comment(linker, &quo ...

  7. UVa 10305 Ordering Tasks (例题 6-15)

    传送门: https://uva.onlinejudge.org/external/103/10305.pdf 拓扑排序(topological sort)简单题 自己代码的思路来自: ==>  ...

  8. M - Ordering Tasks(拓扑排序)

    M - Ordering Tasks Time Limit:3000MS     Memory Limit:0KB     64bit IO Format:%lld & %llu Descri ...

  9. Ordering Tasks 拓扑排序

    John has n tasks to do. Unfortunately, the tasks are not independent and the execution of one task i ...

  10. uva 10305 ordering tasks(超级烂题)——yhx

    aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAABHIAAAHDCAYAAABI5T2bAAAgAElEQVR4nOydPY7svLW1awQGNABHCm

随机推荐

  1. OpenGL入门程序二:绘制简单的圆

    学习 绘制一个圆: ; const float Pi = 3.1415926536f; const float R = 0.5f; //绘制一个圆 void DrawCircle() { //绘制一个 ...

  2. infra 仪表盘效果

    private void Gauge2() { // Infragistics.WebUI.UltraWebGauge.UltraGauge ultraGauge2 = //new Infragist ...

  3. R & ggplot2 & Excel绘图(直方图/经验分布图/QQ图/茎叶图/箱线图)实例

    持续更新~ 散点图 条形图 文氏图 饼图 盒型图 频率直方图 热图 PCA图 3D图 火山图 分面图 分面制作小多组图 地图 练习数据: year count china Ame jap '12 2. ...

  4. 20170731xlVba根据数据表和模板表生成新表

    Public Sub SplitData() Dim Wb As Workbook Dim Sht As Worksheet Dim NewSht As Worksheet Dim arr As Va ...

  5. Java compiler level does not match the version of the installed Java project facet.解决方法

    右键项目“Properties”,在弹出的“Properties”窗口左侧,单击“Project Facets”,打开“Project Facets”页面. 在页面中的“Java”下拉列表中,选择相应 ...

  6. php-fpm.conf配置文件中文说明详解及重要参数说明

    摘自:https://www.jb51.net/article/148550.htm 感谢分享 php-fpm工作流程 php-fpm全名是PHP FastCGI进程管理器 php-fpm启动后会先读 ...

  7. qxx 项目总结

    一.账号池功能 1. 右边注释添加格式 private $client; // Jyeoo的接口 2. 将一些配置放到某个配置文件中,然后通过加载配置环境,来获取相关的变量 app()->con ...

  8. python-day67--MTV之Template

    一.什么是模板? html+模板语法 二.模版包括在使用时会被值替换掉的 变量,和控制模版逻辑的 标签. 三.嵌入变量的三种方式: def current_time(req): # ========= ...

  9. sql server数据库中char、nchar、varchar、nvarchar的选择

    在数据库中,字符型的数据是最多的,可以占到整个数据库的80%以上.为此正确处理字符型的数据,对于提高数据库的性能有很大的作用. 在字符型数据中,用的最多的就是Char与Varchar两种类型.前面的是 ...

  10. js 正则去除指定的单词

    以企业邮箱为例:@后面不能是qq   126   163  188 gmail   yahoo   sina   hotmail  suhu   sogu  等单词. <!DOCTYPE htm ...