0
已解决
贾天宇
高级守护
高级守护
??????????????????
我是WA:
#include <bits/stdc++.h> #define N 200000+100 using namespace std; int n, m, num, nt[N], p[N], q[N], b[N]; bool flag[N]; long long dist[N], w[N]; void add(int x, int y, long long z) { b[++num] = y; w[num] = z; nt[num] = p[x]; p[x] = num; } struct Node { int bh; long long dist; Node(int x, long long y) { bh = x; dist = y; } bool operator <(const Node &s)const { return s.dist<dist; } }; void dijkstra(int st) { for (int i = 1; i <= n; ++i)dist[i] = 2147483647; dist[st] = 0; priority_queue<Node>q; q.push(Node(st, 0)); while (!q.empty()) { Node k = q.top(); q.pop(); if (!flag[k.bh]) { flag[k.bh] = true; int e = p[k.bh]; while (e) { int kk = b[e]; if (dist[kk] - dist[k.bh]>w[e]) dist[kk] = dist[k.bh] + w[e]; q.push(Node(kk, dist[kk])); e = nt[e]; } } } } int main() { int st; scanf("%d%d%d", &n, &m, &st); for (int i = 1; i <= m; ++i) { int x, y; long long z; scanf("%d%d%lld", &x, &y, &z); add(x, y, z); } dijkstra(st); for (int i = 1; i <= n; ++i) printf("%lld ", dist[i]); return 0; }
大佬找茬;谢谢;
贾天宇在2018-12-17 21:08:38追加了内容
大佬们,就帮帮我这个菜鸡吧!!!!!!!
又是一个WA:
#include<iostream> #include<cstdio> #include<cstring> #include<algorithm> #include<cmath> using namespace std; #define ll long long #define II int #define R register #define mmax 20002 #define inf 0x7ffffff II n,m,ans; II tu[102][mmax],da[mmax]; II mxsum(II *x){ II th=0; II mx=0; for(R II i=1;i<=n;++i){ th+=x[i]; if(th<0)th=0; else if(th>mx)mx=th; } return mx; } int main() { cin>>m>>n; for(int i=1;i<=m;i++) for(int j=1;j<=n;j++) { cin>>tu[i][j]; } for(int i=1;i<=n;i++) { da[i]=-inf; for(int j=1;j<=m;j++) if(tu[j][i]>da[i]) { da[i]=tu[j][i]; } } cout<<mxsum(da)<<endl; return 0; }