#include <bits/stdc++.h>
using namespace std;
const int maxn = 105;
struct node
{
int situation, yuzhi;
}ns[maxn];
std::vector<int> g[maxn];
int main() {
int n, p;
cin >> n >> p;
queue<int> q;
int vis[maxn];
bool qidian[maxn];
memset(vis, 0, sizeof(vis));
for(int i = 1; i <= n; i++) {
cin >> ns[i].situation >> ns[i].yuzhi;
if(ns[i].situation) {
q.push(i);
qidian[i] = 1;
vis[i] = 1;
}
}
int weigh[maxn][maxn];
for(int i = 1; i <= p; i++) {
int x, y, z;
cin >> x >> y >> z;
g[x].push_back(y);
weigh[x][y] = z;
}
while(!q.empty()) {
int x = q.front();
q.pop();
if(!qidian[x]) ns[x].situation -= ns[x].yuzhi;
if(ns[x].situation > 0) {
vector<int>::iterator it;
for(it = g[x].begin(); it != g[x].end(); it++) {
ns[*it].situation += weigh[x][*it] * ns[x].situation;
if(!vis[*it]) {
q.push(*it);
vis[*it] = 1;
}
}
}
}
bool flag = true;
for(int i = 1; i <= n; i++) {
if(g[i].empty() && ns[i].situation > 0) {
flag = false;
cout << i << ' ' << ns[i].situation << endl;
}
}
if(flag) cout << "NULL";
}

P1038 神经网络的更多相关文章

  1. 洛谷P1038 神经网络==codevs1088 神经网络

    P1038 神经网络 题目背景 人工神经网络(Artificial Neural Network)是一种新兴的具有自我学习能力的计算系统,在模式识别.函数逼近及贷款风险评估等诸多领域有广泛的应用.对神 ...

  2. 洛谷P1038 神经网络

    P1038 神经网络 题目背景 人工神经网络(Artificial Neural Network)是一种新兴的具有自我学习能力的计算系统,在模式识别.函数逼近及贷款风险评估等诸多领域有广泛的应用.对神 ...

  3. 洛谷——P1038 神经网络

    P1038 神经网络 题目背景 人工神经网络(Artificial Neural Network)是一种新兴的具有自我学习能力的计算系统,在模式识别.函数逼近及贷款风险评估等诸多领域有广泛的应用.对神 ...

  4. 洛谷 P1038 神经网络 Label:拓扑排序 && 坑 60分待查

    题目背景 人工神经网络(Artificial Neural Network)是一种新兴的具有自我学习能力的计算系统,在模式识别.函数逼近及贷款风险评估等诸多领域有广泛的应用.对神经网络的研究一直是当今 ...

  5. 洛谷P1038 神经网络(bfs,模拟,拓扑)

    题目背景 人工神经网络(Artificial Neural NetworkArtificialNeuralNetwork)是一种新兴的具有自我学习能力的计算系统,在模式识别.函数逼近及贷款风险评估等诸 ...

  6. 洛谷 P1038 神经网络

    题目背景 人工神经网络(Artificial Neural Network)是一种新兴的具有自我学习能力的计算系统,在模式识别.函数逼近及贷款风险评估等诸多领域有广泛的应用.对神经网络的研究一直是当今 ...

  7. [NOIP2003] 提高组 洛谷P1038 神经网络

    题目背景 人工神经网络(Artificial Neural Network)是一种新兴的具有自我学习能力的计算系统,在模式识别.函数逼近及贷款风险评估等诸多领域有广泛的应用.对神经网络的研究一直是当今 ...

  8. P1038 神经网络[拓扑]

    题目背景 人工神经网络(Artificial Neural Network)是一种新兴的具有自我学习能力的计算系统,在模式识别.函数逼近及贷款风险评估等诸多领域有广泛的应用.对神经网络的研究一直是当今 ...

  9. Luogu P1038 神经网络

    qwq 拓扑排序模板题. 拓扑排序,是在一个$DAG$中,其拓扑排序为其所有结点的一个线性排序(答案不唯一). 该排序满足这样的条件——对于图中的任意两个结点$u$和$v$,若存在一条有向边从$u$指 ...

随机推荐

  1. OpenCV 线性混合(4)

      带滚动条的线性混合示例:   #include "stdafx.h" #include<iostream> #include<thread> #incl ...

  2. SPOJ TSUM Triple Sums(FFT + 容斥)

    题目 Source http://www.spoj.com/problems/TSUM/ Description You're given a sequence s of N distinct int ...

  3. 百度地图API使用记录

    用户数据图层的总教程: 就是把用户数据存到LBS云里面,应用从云里面读数据 http://developer.baidu.com/map/jsdevelop-9.htm 上传数据的地方: http:/ ...

  4. 【Xcelsius】在PPT中嵌入水晶易表Xcelsius2008仪表盘

    如果您使用Xcelsius创建了动画图形,并将其保存为 Shockwave® 文件(.swf 文件扩展名).但是往往插入进去之后,会产生一些比较棘手的问题,比如ppt不会自动播放,错误等等.今天把这些 ...

  5. ccc 音乐播放

    cc.Class({ extends: cc.Component, properties: { musicPlayer: { default: null, type: cc.AudioSource } ...

  6. Darkest page of my coding life

    The code i wrote a while ago recently caused a disaster and as I reviewed it I found it is the silli ...

  7. ACM Arithmetic Expression

    Description Given N arithmetic expressions, can you tell whose result is closest to 9? Input Line 1: ...

  8. 【BZOJ2190】【SDOI2008】仪仗队

    Description 作为体育委员,C君负责这次运动会仪仗队的训练.仪仗队是由学生组成的N * N的方阵,为了保证队伍在行进中整齐划一,C君会跟在仪仗队的左后方,根据其视线所及的学生人数来判断队伍是 ...

  9. BZOJ2322: [BeiJing2011]梦想封印

    Description 渐渐地,Magic Land上的人们对那座岛屿上的各种现象有了深入的了解. 为了分析一种奇特的称为梦想封印(Fantasy Seal)的特技,需要引入如下的概念: 每一位魔法的 ...

  10. Photoshop教您快速的制作标准一寸证件照教程

    Photoshop教您快速的制作标准一寸证件照教程 对急需证件照的朋友,只要有一部相机,有电脑安装了PS软件,就可很快自己完成一寸照片的制作. 首先将相机卡里的照片存放在电脑硬盘里: 打开PS图片处理 ...