P1038 神经网络
#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 神经网络的更多相关文章
- 洛谷P1038 神经网络==codevs1088 神经网络
P1038 神经网络 题目背景 人工神经网络(Artificial Neural Network)是一种新兴的具有自我学习能力的计算系统,在模式识别.函数逼近及贷款风险评估等诸多领域有广泛的应用.对神 ...
- 洛谷P1038 神经网络
P1038 神经网络 题目背景 人工神经网络(Artificial Neural Network)是一种新兴的具有自我学习能力的计算系统,在模式识别.函数逼近及贷款风险评估等诸多领域有广泛的应用.对神 ...
- 洛谷——P1038 神经网络
P1038 神经网络 题目背景 人工神经网络(Artificial Neural Network)是一种新兴的具有自我学习能力的计算系统,在模式识别.函数逼近及贷款风险评估等诸多领域有广泛的应用.对神 ...
- 洛谷 P1038 神经网络 Label:拓扑排序 && 坑 60分待查
题目背景 人工神经网络(Artificial Neural Network)是一种新兴的具有自我学习能力的计算系统,在模式识别.函数逼近及贷款风险评估等诸多领域有广泛的应用.对神经网络的研究一直是当今 ...
- 洛谷P1038 神经网络(bfs,模拟,拓扑)
题目背景 人工神经网络(Artificial Neural NetworkArtificialNeuralNetwork)是一种新兴的具有自我学习能力的计算系统,在模式识别.函数逼近及贷款风险评估等诸 ...
- 洛谷 P1038 神经网络
题目背景 人工神经网络(Artificial Neural Network)是一种新兴的具有自我学习能力的计算系统,在模式识别.函数逼近及贷款风险评估等诸多领域有广泛的应用.对神经网络的研究一直是当今 ...
- [NOIP2003] 提高组 洛谷P1038 神经网络
题目背景 人工神经网络(Artificial Neural Network)是一种新兴的具有自我学习能力的计算系统,在模式识别.函数逼近及贷款风险评估等诸多领域有广泛的应用.对神经网络的研究一直是当今 ...
- P1038 神经网络[拓扑]
题目背景 人工神经网络(Artificial Neural Network)是一种新兴的具有自我学习能力的计算系统,在模式识别.函数逼近及贷款风险评估等诸多领域有广泛的应用.对神经网络的研究一直是当今 ...
- Luogu P1038 神经网络
qwq 拓扑排序模板题. 拓扑排序,是在一个$DAG$中,其拓扑排序为其所有结点的一个线性排序(答案不唯一). 该排序满足这样的条件——对于图中的任意两个结点$u$和$v$,若存在一条有向边从$u$指 ...
随机推荐
- http://m.blog.csdn.net/article/details?id=8237698
http://m.blog.csdn.net/article/details?id=8237698
- Git分支操作
1.创建分支 git branch <分支名> 2.切换分支 git checkout <分支名> 该语句和上一个语句可以和起来用一个语句表示: git checkout -b ...
- bzoj1006 [HNOI2008]神奇的国度
1006: [HNOI2008]神奇的国度 Time Limit: 20 Sec Memory Limit: 162 MBSubmit: 2304 Solved: 1043 Description ...
- Android入门第八篇之GridView(九宫图)
本文来自http://blog.csdn.net/hellogv/ GridView跟ListView都是比较常用的多控件布局,而GridView更是实现九宫图的首选!本文就是介绍如何使用GridVi ...
- Android MuPDF 阅读PDF文件
MuPDF是一款轻量级的开源软件,可以用来阅读PDF文件.下载完源代码以后,想要运行成功,除了Android SDK之外,还需要Android NDK环境,因此有点麻烦. 但是一旦安装完必须的环境以后 ...
- 让mysql有直接写redis能力
1.文件包下载 http://pan.baidu.com/s/1qW9DHYc 2.安装 gcc -fPIC -Wall -I/usr/local/mysql/include/mysql -I. -s ...
- [深入浅出Windows 10]实现饼图控件
13.2 实现饼图控件 上一小节讲解了动态生成折线图和区域图,对于简单的图形这样通过C#代码来生成的方式是很方便的,但是当我们的图表要实现更加复杂的逻辑的时候,这种动态生成的方式就显得力不从心了,那就 ...
- CSS:z-index层级在IE中无效
引用地址:http://apps.hi.baidu.com/share/detail/19853262 在CSS中,只能通过代码改变层级,这个属性就是z-index,要让z-index起作用有个小小前 ...
- C#_数据转换 实用方法
[String转Array]string str = "123asd456asd789";单字符: string[] a0 = str.Split('a');多字符: string ...
- Spring MVC过滤器-字符集过滤器(CharacterEncodingFilter)
spring的字符集过滤通过用于处理项目中的乱码问题,该过滤器位于org.springframework.web.filter包中,指向类CharacterEncodingFilter,Charact ...