新手光能
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<sstream>
#include<string>
#include<iomanip>
#include<vector>
#include<queue>
#include<cstdlib>
using namespace std;
const int INF=100000000;
int n,e;
int G[2010][2010],d[2010],counts[2010];
bool exist[2010];
queue<int> q;
void spfa(int s) {
fill(d+1,d+n+1,INF);
memset(exist,false,sizeof(exist));
d[s]=0;
q.push(s);
exist[s]=true;
counts[s]=1;
while (!q.empty()) {
int v=q.front();
q.pop();
exist[v]=false;
if (v==n) continue;
for (int i=1; i<=n; i++) {
if (d[v]+G[v][i]<d[i]) {
d[i]=d[v]+G[v][i];
counts[i]=counts[v];
} else {
counts[i]+=counts[v];
}
if (!exist[i]) {
q.push(i);
exist[i]=true;
}
}
counts[v]=0;
}
}
int main() {
cin>>n>>e;
for (int i=1; i<=n; i++) {
fill(G[i]+1,G[i]+n+1,INF);
}
for (int i=1; i<=e; i++) {
int u,v,t;
cin>>u>>v>>t;
G[u][v]=min(G[u][v],t);
}
spfa(1);
if (d[n]==INF) cout<<"No answer"<<endl;
else cout<<d[n]<<" "<<counts[n]<<endl;
return 0;
}