0分代码,不懂为啥会运行错误,看了几个博客说要对D取模。没懂,先放没过的代码,代码做优化了已经,奈何过不了。
题目链接
代码:
#include <bits/stdc++.h>
using namespace std;
// #define double long double
// #define int long long
const int N = 10000010;
const int P = 10000010;
int n,s,p,T;
double Time_interval; //时间间隔
int r[N+P];
double I[N];
int maichong[N];
struct Node{
int v;
double w;
int d;
};
vector<vector<Node> > edge; // 有没有两个突触的入结点和出节点相同?
double vv[N],uu[N],aa[N],bb[N],cc[N],dd[N];
struct Rec{
int t; //时刻t收到
int v; // 神经元v是接收者
double w; // 脉冲大小
bool operator<(const Rec o)const{
return o.t<t;
}
};
priority_queue<Rec> q; // 按照时刻排序脉冲 t v w
static unsigned long long nxt = 1;
/* RAND_MAX assumed to be 32767 */
int myrand(void) {
nxt = nxt * 1103515245 + 12345;
return((unsigned)(nxt/65536) % 32768);
}
signed main()
{
cin >> n >> s >> p >> T;
cin >> Time_interval;
edge.resize(N+P+2);
int cnt = 0;
while(true){
int rn;
double v,u,a,b,c,d;
scanf("%d",&rn);
// 一段连续编号的神经元的信息
for(int i=cnt;i<rn+cnt;i++){
scanf("%lf%lf%lf%lf%lf%lf",&v,&u,&a,&b,&c,&d); // 六个实数
vv[i] = v;uu[i] = u;aa[i] = a;bb[i] = b;cc[i] = c;dd[i] = d;
}
cnt += rn;
if(cnt==n) break;
}
for(int i=n;i<n+p;i++){
scanf("%d",&r[i]); // 正整数
}
for(int i=1;i<=s;i++){
int u,v,d;
scanf("%d%d",&u,&v);
double w;
scanf("%lf%d",&w,&d);
edge[u].push_back((Node){v,w,d});
}
for(int time = 1;time <= T;time ++){
for(int j=n;j<n+p;j++){
if(r[j] > myrand()){
for(auto rng:edge[j]){
q.push({time+rng.d,rng.v,rng.w});
}
}
}
for(int i=0;i<n;i++) I[i] = 0;
while(!q.empty() && q.top().t==time){
auto qt = q.top();
q.pop();
I[qt.v] += qt.w;
}
for(int i=0;i<n;i++){
double u = uu[i],v = vv[i];
vv[i] = v + Time_interval*(0.04*v*v+5*v+140-u) + I[i];
uu[i] = u + Time_interval*aa[i]*(bb[i]*v-u);
// cout << "v + Time_interval*(0.04*v*v+5*v+140-u) + I[i] = "
// << (v + Time_interval*(0.04*v*v+5*v+140-u) + I[i]) << endl;
// update ans
if(vv[i]>=30){
for(auto rng:edge[i]){
q.push({time+rng.d,rng.v,rng.w});
}
maichong[i]++;
vv[i] = cc[i];
uu[i] += dd[i];
}
}
}
double ans1 = 2e9,ans2 = -2e9;
for(int i=0;i<n;i++){
ans1 = min(ans1,vv[i]);
ans2 = max(ans2,vv[i]);
}
int res1 = 1e9,res2 = 0;
for(int i=0;i<n;i++){
res1 = min(res1,maichong[i]);
res2 = max(res2,maichong[i]);
}
// cout << ans1 << ' ' << ans2 << '\n' << res1 << ' ' << res2 << '\n';
printf("%.3lf %.3lf\n%d %d\n",ans1,ans2,res1,res2);
return 0;
}