灵异事件求助

P4568 [JLOI2011] 飞行路线

@[protractor](/user/964822) 加了个st数组标记后不会在开O2的情况下不会RE了( ```cpp #include<iostream> #include<vector> #include<cstring> #include<queue> using namespace std; struct hangxian{ int y,z; }; struct dian{ int id,k,data; bool operator < (dian rhs)const{ return data>rhs.data; } }; vector<hangxian> v[10050]; int n,m,k,s,t,a,b,c; int f[10050][15]; bool st[10050][15]; void dij(int x) { priority_queue<dian> pq; dian y; y.id=x,y.k=k,y.data=0; pq.push(y); while(!pq.empty()) { y=pq.top(); cout<<n<<' '<<k<<' '<<y.id<<endl; pq.pop(); if(st[y.id][y.k])continue; st[y.id][y.k]=true; for(auto xx : v[y.id]) { if(f[xx.y][y.k]>f[y.id][y.k]+xx.z) { f[xx.y][y.k]=f[y.id][y.k]+xx.z; dian yy; yy.id=xx.y,yy.k=y.k,yy.data=f[xx.y][y.k]; pq.push(yy); } if(f[xx.y][y.k-1]>f[y.id][y.k]) { f[xx.y][y.k-1]=f[y.id][y.k]; dian yy; yy.id=xx.y,yy.k=y.k-1,yy.data=f[xx.y][y.k]; pq.push(yy); } cout << 114514 << endl; } cout << "_-----" << endl; } } int main() { memset(f,0x3f,sizeof f); cin>>n>>m>>k>>s>>t; for(int i=1;i<=m;i++) { cin>>a>>b>>c; hangxian x,y; x.y=b,x.z=c,y.y=a,y.z=c; v[a].push_back(x); v[b].push_back(y); } f[s][k]=0; cout << 114514 << endl; dij(s); cout << 114514 << endl; int ans=2147483647; cout<<n<<' '<<k<<'\n'; for(int i=k;i>=0;i--) { for(int j=0;j<n;j++) cout<<f[j][i]<<' '; cout<<'\n'; } for(int i=0;i<=k;i++) ans=min(ans,f[t][i]); cout<<ans; return 0; } ```
by QWQ_123 @ 2024-02-20 21:43:06


@[protractor](/user/964822) 这下更灵异了,我把调试语句删掉以后RE了,然后加上就运行成功了。
by QWQ_123 @ 2024-02-20 21:49:30


谢谢大佬 @[QWQ_123](/user/740328) 这个代码没救了T_T,我重构吧
by protractor @ 2024-02-20 22:03:26


我dij写的和shi一样,就没有写对过一次
by protractor @ 2024-02-20 22:04:01


@[QWQ_123](/user/740328) 等等,RE了????
by protractor @ 2024-02-20 22:07:52


~~第一篇代码创造的神贴~~
by protractor @ 2024-02-20 22:08:40


调试代码怎么你了 ~~@~~ IDE
by protractor @ 2024-02-20 22:09:49


@[QWQ_123](/user/740328) 本蒟蒻有几次不先加 `cout<<"";` 就没有输出
by _buzhidao_ @ 2024-02-20 22:46:31


谢谢大家的帮助,问题解决了,是没有判断数组越界导致的RE
by protractor @ 2024-03-08 21:28:27


|