#include <iostream>
#include <cstdio>
#include <vector>
#include <unordered_map>
#include <iomanip>
using namespace std;
const int MAX_NUM = 10000;
// 脉冲元素
int r[MAX_NUM];
//神经元元素
double I[MAX_NUM][1001];
double v[MAX_NUM];
double u[MAX_NUM];
double a[MAX_NUM];
double b[MAX_NUM];
vector<int> cnt;
int max_cnt = -1;
int min_cnt = 2 << 29;
double max_v = -1000000;
double min_v = 2 << 29;
// 发送完脉冲后的默认值
double c[MAX_NUM];
double d[MAX_NUM];
//突触元素
struct nn
{
int tail;
double w;
int D;
};
// unordered_map<int, unordered_map<int, double>> w;
// unordered_map<int, unordered_map<int, int>> D;
unordered_map<int, vector<nn>> edge;
unordered_map<int, vector<int>> go;
int S_in[MAX_NUM];
int S_out[MAX_NUM];
double dt = 0;
static unsigned long next0 = 1;
/* RAND_MAX assumed to be 32767 */
int myrand(void) {
next0 = next0 * 1103515245 + 12345;
return((unsigned)(next0/65536) % 32768);
}
double cv(int i,int k)
{
return v[i] + dt * (0.04 * v[i] * v[i] + 5 * v[i] + 140 - u[i]) + I[i][k];
}
double cu(int i)
{
return u[i] + dt * a[i] * (b[i] * v[i] - u[i]);
}
int main()
{
int N, P, S, T;
cin >> N >> S >> P >> T;
cin >> dt;
int tmp_N = N;
int cnt_N = 0;
while(tmp_N > 0)
{
int RN;
cin >> RN;
double vv , uu, aa, bb, cc, dd;
cin >> vv >> uu >> aa >> bb >> cc >> dd;
for (int i = 0; i < RN; i++)
{
int tmp_cnt_N = cnt_N++;
//cout << tmp_cnt_N << endl;
v[tmp_cnt_N] = vv;u[tmp_cnt_N] = uu;a[tmp_cnt_N] = aa;b[tmp_cnt_N] = bb;c[tmp_cnt_N] = cc;d[tmp_cnt_N] = dd;
cnt.push_back(0);
}
tmp_N -= RN;
}
for (int i = 0; i < P; i++)
{
cin >> r[i + N];
}
for (int i = 0; i < S; i++)
{
nn nn_t;
cin >> S_in[i] >> nn_t.tail;
cin >> nn_t.w;
cin >> nn_t.D;
//go[S_in[i]].push_back(S_out[i]);
edge[S_in[i]].push_back(nn_t);
}
for (int time = 1; time <= T; time++)
{
// 首先处理脉冲源来计算IK,还有突触
for (int i = 0; i < P; i++)
{
int nows = i + N;
int em = myrand();
if(r[nows] > em)
{
int len = edge[nows].size();
for (int i = 0; i < len; i++)
{
int next_i = edge[nows][i].tail;
int D_i = edge[nows][i].D;
int w_i = edge[nows][i].w;
I[next_i][time + D_i] += w_i;
//cout << nows <<" " << next_i << " "<< w_i << endl;
}
}
}
// 其次再分析神经元
for (int i = 0; i < N; i++)
{
int nows = i;
// 更新v 和 u
double v_nows = cv(nows, time);
double u_nows = cu(nows);
v[nows] = v_nows;
u[nows] = u_nows;
//判断是否传播
if(v[nows] >= 30)
{
v[nows] = c[nows];
u[nows] += d[nows];
cnt[nows]++;
int len = edge[nows].size();
for (int i = 0; i < len; i++)
{
int next_i = edge[nows][i].tail;
int D_i = edge[nows][i].D;
int w_i = edge[nows][i].w;
I[next_i][time + D_i] += w_i;
//cout << nows <<" " << next_i << " "<< w_i << endl;
}
}
//cout << v[nows] << " ";
}
//cout << endl;
}
for (int i = 0; i < N; i++)
{
if(v[i] > max_v)
max_v = v[i];
if(v[i] < min_v)
min_v = v[i];
if(cnt[i] > max_cnt)
max_cnt = cnt[i];
if(cnt[i] < min_cnt)
min_cnt = cnt[i];
}
cout << fixed << setprecision(3)<< min_v << " " << max_v << endl;
cout << min_cnt << " " << max_cnt;
return 0;
}
csp 202109-3 脉冲神经网络 我自己本地测了半天找不出错误,提交上去是0分, 希望有人能帮我找到错误样例
- 写回答
- 好问题 0 提建议
- 追加酬金
- 关注问题
- 邀请回答
-
1条回答 默认 最新
- SmallAntJ 2022-05-09 06:03关注
你可以到 AcWing 上测试,错误样例太长了我就不在这贴了。
4008. 脉冲神经网络 - AcWing题库 高质量的算法题库 https://www.acwing.com/problem/content/4011/解决 1无用
悬赏问题
- ¥15 如何让企业微信机器人实现消息汇总整合
- ¥50 关于#ui#的问题:做yolov8的ui界面出现的问题
- ¥15 如何用Python爬取各高校教师公开的教育和工作经历
- ¥15 TLE9879QXA40 电机驱动
- ¥20 对于工程问题的非线性数学模型进行线性化
- ¥15 Mirare PLUS 进行密钥认证?(详解)
- ¥15 物体双站RCS和其组成阵列后的双站RCS关系验证
- ¥20 想用ollama做一个自己的AI数据库
- ¥15 关于qualoth编辑及缝合服装领子的问题解决方案探寻
- ¥15 请问怎么才能复现这样的图呀